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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions winget-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ function Test-ModsUninstall ($AppID){
}

#Install function
function Install-App ($AppID){
function Install-App ($AppID,$AppArgs){
$IsInstalled = Confirm-Install $AppID
if (!($IsInstalled)){
#Install App
Write-Log "Installing $AppID..." "Yellow"
& $winget install --id $AppID --silent --accept-package-agreements --accept-source-agreements
$Command = "$winget install --id $AppID --silent --accept-package-agreements --accept-source-agreements $AppArgs"
cmd.exe /c $Command

#Check if mods exist
$ModsInstall = Test-ModsInstall $AppID
if ($ModsInstall){
Expand All @@ -184,12 +186,14 @@ function Install-App ($AppID){
}

#Uninstall function
function Uninstall-App ($AppID){
function Uninstall-App ($AppID,$AppArgs){
$IsInstalled = Confirm-Install $AppID
if ($IsInstalled){
#Uninstall App
Write-Log "Uninstalling $AppID..." "Yellow"
& $winget uninstall --id $AppID --silent --accept-source-agreements
$Command = "$winget uninstall --id $AppID --silent --accept-source-agreements $AppArgs"
cmd.exe /c $Command

#Check if mods exist
$ModsUninstall = Test-ModsUninstall $AppID
if ($ModsUninstall){
Expand Down Expand Up @@ -276,20 +280,23 @@ Init
Get-WingetCmd

#Run install or uninstall for all apps
foreach ($AppID in $AppIDs){
foreach ($App_Full in $AppIDs){
#Split AppID and Custom arguments
$AppID, $AppArgs = ($App_Full.Trim().Split(" ",2))

#Check if app exists on Winget Repo
$Exists = Confirm-Exist $AppID
if ($Exists){
#Install or Uninstall command
if ($Uninstall){
Uninstall-App $AppID
Uninstall-App $AppID $AppArgs
#Add to WAU White List if set
if ($WAUWhiteList){
Remove-WAUWhiteList $AppID
}
}
else{
Install-App $AppID
Install-App $AppID $AppArgs
#Remove from WAU White List if set
if ($WAUWhiteList){
Add-WAUWhiteList $AppID
Expand Down