Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: How do I handle quoting correctly in override mod? #691

Open
RuppMartin001 opened this issue Sep 7, 2024 · 6 comments
Open

[Bug]: How do I handle quoting correctly in override mod? #691

RuppMartin001 opened this issue Sep 7, 2024 · 6 comments
Labels
bug Something isn't working stale

Comments

@RuppMartin001
Copy link

RuppMartin001 commented Sep 7, 2024

The problem

I want to specify INSTALLDIR in override. How can I do this with spaces in paths?
Should the whole line in the override mod file be quoted also?

E.g. my content of file: "Microsoft.OpenJDK.11-override.txt" seems to work:
ADDLOCAL=FeatureMain INSTALLDIR=""C:\Program Files\Java\Microsoft\jdk11"" /qn

But I have issues with musescore.
I want to have it installed for all users.
I tried this one:
'ALLUSERS=1 INSTALLDIR=""C:\Program Files\MuseScore"" /qn'.

Id:
Musescore.Musescore

And I have issues with grepWin to have it installed for all users:

Id:
StefansTools.grepWin
I have it installed via:
winget install --id StefansTools.grepWin -e --scope machine --override "ALLUSERS=1"

But with ALLUSERS=1 /qn in StefansTools.grepWin-override.txt it tries to update it for the current user.
How do I handle this correctly?
And how should be the quotes in the override file?
Single quotes?
Double quotes?
Escaped quotes for powershell, like `" or `'?
Escaped quotes for cmd shell like \" or \'?

What version of WAU has the issue?

1.21.2

What version of Windows are you using (ex. Windows 11 22H2)?

Windows 10 22H2 (Build19045.4780)

What version of winget are you using?

v1.8.1911 (system via % $WingetCmd)

Log information

No response

Additional information

No response

@RuppMartin001 RuppMartin001 added the bug Something isn't working label Sep 7, 2024
@KnifMelti
Copy link
Contributor

KnifMelti commented Sep 7, 2024

MuseScore doesn't have the SecureCustomProperty INSTALLDIR, it uses INSTALL_ROOT (grepWin uses APPLICATIONFOLDER) instead.
Only in grepWin there's an ALLUSERS.

If System installs either of them straight up the shortcut installs to:
C:\Windows\System32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

So, not every MSI follows the standard!

Have you tried with "INSTALL_ROOT=""C:\Program Files\MuseScore"" /qn" for MuseScore? (see EDIT2 - this is a winget/DOS thing, no bug in WAU)
But the shortcuts will have to be copied to all users start menu...

With StefansTools.grepWin-override.txt containing ALLUSERS=1 /qn I don't have a problem (an older version installed before in System Context with the same override ):

image

It works like this.
If an $app-override.txt is present all the content will be read inte the variable: $ModsOverride = Get-Content "$Mods\$app-override.txt" -Raw
It then will be upgraded using: & $Winget upgrade --id $($app.Id) -e --accept-package-agreements --accept-source-agreements -s winget --override $ModsOverride | Where-Object { $_ -notlike " *" } | Tee-Object -file $LogFile -Append

So, the content of the file $app-override.txt is passed to winget via --override $ModsOverride

EDIT: Regarding quotes and escaping; raw, as the receiving installation expect it...
EDIT2: And as winget runs in DOS Using "Double Quotes" when it comes to parameters with space, so for example the StefansTools.grepWin-override.txt should contain:
"APPLICATIONFOLDER=""C:\Program Files\grepDOS"" ALLUSERS=1 /qn" if you want to install it for all users in a different place than default

@RuppMartin001
Copy link
Author

RuppMartin001 commented Sep 10, 2024

Thank you for your detailed answer!

Is it not necessary to quote the parameter like --override "$ModsOverride"?

In the log is following line:
-> Running (overriding default): Winget upgrade --id StefansTools.grepWin -e --accept-package-agreements --accept-source-agreements -s winget --override ALLUSERS=1 APPLICATIONFOLDER=""C:\Program Files\grepWin"" /qn

Should it not be --override "ALLUSERS=1 APPLICATIONFOLDER=`"C:\Program Files\grepWin`" /qn" instead of: --override ALLUSERS=1 APPLICATIONFOLDER=""C:\Program Files\grepWin"" /qn ?

I have tried this lines to install an old version of grepWin (via DOS shell, started as admin):

Works:
winget install -e --id StefansTools.grepWin --version 2.1.1340 --override "ALLUSERS=1 APPLICATIONFOLDER=\"C:\Program Files\grepWin\" /qn"

Doesn't work:
winget install -e --id StefansTools.grepWin --version 2.1.1340 --override ALLUSERS=1 APPLICATIONFOLDER=""C:\Program Files\grepWin"" /qn

@RuppMartin001
Copy link
Author

grafik

I think winget is a native command in the perspective of Powershell.

I will try the TestExe program:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing?view=powershell-5.1#passing-arguments-that-contain-quote-characters

@KnifMelti
Copy link
Contributor

I think winget is a native command in the perspective of Powershell.

No, not if you don't have PowerShell Module for the Windows Package Manager Client installed.
WAU constructs the variable $Winget ($Script:Winget = Get-WingetCmd) from searching after the binary in Get-WingetCmd.ps1 and then runs it externally via & $Winget with the & operator used to execute a command.

@KnifMelti
Copy link
Contributor

KnifMelti commented Sep 10, 2024

Is it not necessary to quote the parameter like --override "$ModsOverride"?

Like I wrote:
The content of the file $app-override.txt meaning that if you have "APPLICATIONFOLDER=""C:\Program Files\grepDOS"" ALLUSERS=1 /qn" in it all of that will be passed after --override
And that StefansTools.grepWin-override.txt works for me.

Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

2 participants