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

Add custom arguments for app installation #19

Merged
merged 1 commit into from
Apr 11, 2022
Merged

Conversation

Romanitho
Copy link
Owner

@Romanitho Romanitho commented Apr 11, 2022

You can now push customs arguments with this change:
powershell.exe -Executionpolicy Bypass -File winget-install.ps1 -AppIDs "7zip.7zip --version 21.06"

and for multiple apps at once:
powershell.exe -Executionpolicy Bypass -Command .\winget-install.ps1 -AppIDs '7zip.7zip --version 21.06','Notepad++.Notepad++ --version 8.3.1 --override "/S"'

@Romanitho Romanitho added the enhancement New feature or request label Apr 11, 2022
@Romanitho Romanitho merged commit 5bd4df3 into main Apr 11, 2022
@Romanitho Romanitho deleted the Custom-Arguments branch April 11, 2022 10:48
@Romanitho Romanitho linked an issue Apr 11, 2022 that may be closed by this pull request
@KnifMelti
Copy link
Contributor

@Romanitho
It seems something is wrong with this implementation.
winget doesn't succeed in installing/uninstalling...
...changed back to the old "& $winget install --id $AppID --silent --accept-package-agreements --accept-source-agreements" then everything works again.

@KnifMelti
Copy link
Contributor

KnifMelti commented Apr 12, 2022

As system via SCCM (as an example):
Install = powershell.exe -windowstyle hidden -executionpolicy bypass -file winget-install.ps1 -AppIDs ultrapico.expresso -WAUWhiteList
Uninstall = powershell.exe -windowstyle hidden -executionpolicy bypass -file winget-install.ps1 -AppIDs ultrapico.expresso -Uninstall -WAUWhiteList

In Windows\Temp\WinGet the logs is ok in creation "WinGet-2022-04-12-14-24-27.012.log" etc.. ..but it never creates "WinGet-ultrapico.expresso.3.1.7917-2022-04-12-14-21-04.585.log" or the associated directory for download.
Can't find any errors in the log...

@Romanitho
Copy link
Owner Author

@Romanitho It seems something is wrong with this implementation. winget doesn't succeed in installing/uninstalling... ...changed back to the old "& $winget install --id $AppID --silent --accept-package-agreements --accept-source-agreements" then everything works again.

Can you post the command line you try to run please ?

@KnifMelti
Copy link
Contributor

Nothing fancy, just an ordinary single install as above.
It's the custom argument thing with cmd that fails somehow

@Romanitho
Copy link
Owner Author

Have you tried this :
powershell.exe -windowstyle hidden -executionpolicy bypass -command .\winget-install.ps1 -AppIDs 'ultrapico.expresso --override "Your Options With Double Quote"' -WAUWhiteList

@KnifMelti
Copy link
Contributor

I'm not using options, just "-AppIDs ultrapico.expresso -Uninstall -WAUWhiteList"
It's like the new cmd part never runs or fail running.
Edited the lines back to old way and everything is ok.

@Romanitho
Copy link
Owner Author

Romanitho commented Apr 12, 2022

I will not have time to troubleshoot tonight, but I need to double check what was added and why it fails.
And I need to add more stuffs in logs. Atm, its not clear at all :/

@Romanitho
Copy link
Owner Author

I'm not using options, just "-AppIDs ultrapico.expresso -Uninstall -WAUWhiteList" It's like the new cmd part never runs or fail running. Edited the lines back to old way and everything is ok.

The thing is, with old way, I can't get --override working

@Romanitho
Copy link
Owner Author

Romanitho commented Apr 12, 2022

Ok, I think I got it... --override is not supported with "uninstall" parameter. I fix that now

Edit : it works for me without touching anything.

@Romanitho
Copy link
Owner Author

on my lab, install and uninstall work with this version.

@KnifMelti
Copy link
Contributor

This is the only way it's working for me:
#Install App
Write-Log "Installing $AppID..." "Yellow"
$Command = "install --id $AppID --silent --accept-package-agreements --accept-source-agreements $AppArgs"
Start-Process -FilePath “$winget” -ArgumentList "$Command" -NoNewWindow -Wait

    #Uninstall App
    Write-Log "Uninstalling $AppID..." "Yellow"
    $Command = "uninstall --id $AppID --silent --accept-source-agreements $AppArgs"
    Start-Process -FilePath “$winget” -ArgumentList "$Command" -NoNewWindow -Wait 

@KnifMelti
Copy link
Contributor

With Start-Process --override should work too.
But, if its only me, I'll have my fork ;)

@Romanitho
Copy link
Owner Author

No, we need ro figure it out. You might not be the only one

@KnifMelti
Copy link
Contributor

Well, I can't make sense of it, tested many things.
But, in my mind the Start-Process is better.
I don't think you have to worry about escaping things in the AppaArgs when you don't use CMD!

@Romanitho
Copy link
Owner Author

The thing is, it's arguments in arguments

@KnifMelti
Copy link
Contributor

I'll test some AppaArgs out with Start-Process out and let you know my findings tomorrow at work.

@KnifMelti
Copy link
Contributor

Could you give me a hard example?

@Romanitho
Copy link
Owner Author

Yes. I was thinking about that. Put winget argument in a dedicated argument instead of having it inside the AppID argument. Make more sense

@Romanitho
Copy link
Owner Author

Could you give me a hard example?

I'm on my phone now, but in the issues we have différents cases you can test

@KnifMelti
Copy link
Contributor

Me to.. ..I'll take a look then tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants