Skip to content

Commit

Permalink
Merge pull request #19 from Romanitho/Custom-Arguments
Browse files Browse the repository at this point in the history
Add custom arguments for app installation
  • Loading branch information
Romanitho committed Apr 11, 2022
2 parents 5db1107 + e122054 commit 5bd4df3
Showing 1 changed file with 14 additions and 7 deletions.
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

0 comments on commit 5bd4df3

Please sign in to comment.