-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove unnecessary usage of Get-WmiObject
- Loading branch information
Showing
10 changed files
with
134 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
try { | ||
$packageName = '{{PackageName}}' | ||
$fileType = 'exe' | ||
$silentArgs = '/S' | ||
$validExitCodes = @(0) | ||
$scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition | ||
$ahkFile = "$scriptPath\$packageName.ahk" | ||
$processor = Get-WmiObject Win32_Processor | ||
$is64bit = $processor.AddressWidth -eq 64 | ||
if ($is64bit) { | ||
$unPath = 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' | ||
$installPath = ${env:ProgramFiles(x86)} | ||
} else { | ||
$unPath = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' | ||
$installPath = $Env:ProgramFiles | ||
} | ||
Start-Process 'AutoHotKey' $ahkFile | ||
$unFile = (Get-ItemProperty $unPath\* | Where-Object {$_.DisplayName -like "$packageName*"}).UninstallString | ||
Uninstall-ChocolateyPackage "$packageName" "$fileType" "$silentArgs" "$unFile" -validExitCodes "$validExitCodes" | ||
$cleanup = gci -re $installPath\$packageName* | ?{ -not $_.PSIsContainer } | measure-object -sum -property Length | ||
if ($cleanup -eq $null) { | ||
Remove-Item -Recurse -Force $installPath\$packageName* | ||
} | ||
} catch { | ||
throw $_.Exception | ||
} | ||
$packageName = '{{PackageName}}' | ||
$packageSearch = "GCstar" | ||
$installerType = 'exe' | ||
$silentArgs = '/S' | ||
$validExitCodes = @(0) | ||
$scriptPath = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
$ahkFile = "$scriptPath\$packageName.ahk" | ||
$ahkRun = "$Env:Temp\$(Get-Random).ahk" | ||
Copy-Item $ahkFile $ahkRun -Force | ||
Start-Process 'AutoHotKey' "$ahkRun" | ||
Get-ItemProperty -Path @( 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' ) ` | ||
-ErrorAction:SilentlyContinue ` | ||
| Where-Object { $_.DisplayName -like "$packageSearch*" } ` | ||
| ForEach-Object { Uninstall-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-SilentArgs "$($silentArgs)" ` | ||
-File "$($_.UninstallString)" ` | ||
-ValidExitCodes $validExitCodes } | ||
Remove-Item "$ahkRun" -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
try { | ||
$packageName = '{{PackageName}}' | ||
$fileType = 'exe' | ||
$silentArgs = '/S' | ||
$validExitCodes = @(0) | ||
$processor = Get-WmiObject Win32_Processor | ||
$is64bit = $processor.AddressWidth -eq 64 | ||
if ($is64bit) { | ||
$unPath = 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' | ||
$installPath = ${Env:ProgramFiles(x86)} | ||
} else { | ||
$unPath = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' | ||
$installPath = $Env:ProgramFiles | ||
} | ||
$unFile = (Get-ItemProperty $unPath\$packageName* UninstallString).UninstallString | ||
Uninstall-ChocolateyPackage "$packageName" "$fileType" "$silentArgs" "$unFile" -validExitCodes "$validExitCodes" | ||
} catch { | ||
throw $_.Exception | ||
} | ||
$packageName = '{{PackageName}}' | ||
$packageSearch = "iTALC" | ||
$installerType = 'exe' | ||
$silentArgs = '/S' | ||
$validExitCodes = @(0) | ||
Get-ItemProperty -Path @( 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' ) ` | ||
-ErrorAction:SilentlyContinue ` | ||
| Where-Object { $_.DisplayName -like "$packageSearch" } ` | ||
| ForEach-Object { Uninstall-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-SilentArgs "$($silentArgs)" ` | ||
-File "$($_.UninstallString)" ` | ||
-ValidExitCodes $validExitCodes } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
try { | ||
$packageName = '{{PackageName}}' | ||
$fileType = 'exe' | ||
$silentArgs = '/S' | ||
$validExitCodes = @(0) | ||
$scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition | ||
$ahkFile = "$scriptPath\$packageName.ahk" | ||
$ahkRun = "$Env:Temp\$(Get-Random).ahk" | ||
Copy-Item $ahkFile $ahkRun -Force | ||
$processor = Get-WmiObject Win32_Processor | ||
$is64bit = $processor.AddressWidth -eq 64 | ||
if ($is64bit) { | ||
$unPath = 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' | ||
} else { | ||
$unPath = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' | ||
} | ||
Start-Process 'AutoHotKey' "$ahkRun" | ||
$unFile = (Get-ItemProperty $unPath\$packageName* UninstallString).UninstallString | ||
Uninstall-ChocolateyPackage "$packageName" "$fileType" "$silentArgs" "$unFile" -validExitCodes $validExitCodes | ||
Remove-Item "$ahkRun" | ||
} catch { | ||
throw $_.Exception | ||
} | ||
$packageName = '{{PackageName}}' | ||
$packageSearch = "JStock" | ||
$installerType = 'exe' | ||
$silentArgs = '/S' | ||
$validExitCodes = @(0) | ||
$scriptPath = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
$ahkFile = "$scriptPath\$packageName.ahk" | ||
$ahkRun = "$Env:Temp\$(Get-Random).ahk" | ||
Copy-Item $ahkFile $ahkRun -Force | ||
Start-Process 'AutoHotKey' "$ahkRun" | ||
Get-ItemProperty -Path @( 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' ) ` | ||
-ErrorAction:SilentlyContinue ` | ||
| Where-Object { $_.DisplayName -like "$packageSearch*" } ` | ||
| ForEach-Object { Uninstall-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-SilentArgs "$($silentArgs)" ` | ||
-File "$($_.UninstallString)" ` | ||
-ValidExitCodes $validExitCodes } | ||
Remove-Item "$ahkRun" -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
$packageName = '{{PackageName}}' | ||
$installerType = 'msi' | ||
$partialInstallArgs = '/quiet /qn /norestart TARGETDIR=' | ||
$is64bit = (Get-WmiObject Win32_Processor).AddressWidth -eq 64 | ||
if ($is64bit) {$installPath = ${Env:ProgramFiles(x86)}} else {$installPath = $Env:ProgramFiles} | ||
$installArgs = $($partialInstallArgs + '"' + $installPath + '"') | ||
# due to limitations of Ketarin/chocopkgup when using repos like sf.net: | ||
$url = '{{DownloadUrlx64}}' | ||
$checksum = '{{Checksumx64}}' | ||
$checksum = '{{Checksum}}' | ||
$checksumType = 'sha1' | ||
$installerType = 'msi' | ||
$partialInstallArgs = '/quiet /qn /norestart TARGETDIR=' | ||
if (Get-ProcessorBits 64) { | ||
$installPath = ${Env:ProgramFiles(x86)} | ||
} else { | ||
$installPath = $Env:ProgramFiles | ||
} | ||
$installArgs = $($partialInstallArgs + '"' + $installPath + '"') | ||
$validExitCodes = @(0) | ||
|
||
Install-ChocolateyPackage "$packageName" "$installerType" "$installArgs" "$url" -validExitCodes $validExitCodes -Checksum "$checksum" -ChecksumType "$checksumType" | ||
Install-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-SilentArgs "$silentArgs" ` | ||
-Url "$url" ` | ||
-ValidExitCodes $validExitCodes ` | ||
-Checksum "$checksum" ` | ||
-ChecksumType "$checksumType" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
$packageName = '{{PackageName}}' | ||
$installerType = 'msi' | ||
$partialInstallArgs = '/quiet /qn /norestart TARGETDIR=' | ||
$is64bit = (Get-WmiObject Win32_Processor).AddressWidth -eq 64 | ||
if ($is64bit) {$installPath = ${Env:ProgramFiles(x86)}} else {$installPath = $Env:ProgramFiles} | ||
$installArgs = $($partialInstallArgs + '"' + $installPath + '"') | ||
# due to limitations of Ketarin/chocopkgup when using repos like sf.net: | ||
$url = '{{DownloadUrlx64}}' | ||
$checksum = '{{Checksum}}' | ||
$checksumType = 'sha1' | ||
$installerType = 'msi' | ||
$partialInstallArgs = '/quiet /qn /norestart TARGETDIR=' | ||
if (Get-ProcessorBits 64) { | ||
$installPath = ${Env:ProgramFiles(x86)} | ||
} else { | ||
$installPath = $Env:ProgramFiles | ||
} | ||
$installArgs = $($partialInstallArgs + '"' + $installPath + '"') | ||
$validExitCodes = @(0) | ||
|
||
Install-ChocolateyPackage "$packageName" "$installerType" "$installArgs" "$url" -validExitCodes "$validExitCodes" -checksum "$checksum" -checksumType "$checksumType" | ||
|
||
Install-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-SilentArgs "$silentArgs" ` | ||
-Url "$url" ` | ||
-ValidExitCodes $validExitCodes ` | ||
-Checksum "$checksum" ` | ||
-ChecksumType "$checksumType" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
try { | ||
$packageName = '{{PackageName}}' | ||
$fileType = 'exe' | ||
$silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART' | ||
$validExitCodes = @(0) | ||
|
||
$processor = Get-WmiObject Win32_Processor | ||
$is64bit = $processor.AddressWidth -eq 64 | ||
if ($is64bit) { | ||
$unFile = (Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, UninstallString | Where-Object {$_.DisplayName -like "$packageName*"}).UninstallString | ||
} else { | ||
$unFile = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, UninstallString | Where-Object {$_.DisplayName -like "$packageName*"}).UninstallString | ||
} | ||
Uninstall-ChocolateyPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes | ||
} catch { | ||
throw $_.Exception | ||
} | ||
$packageName = '{{PackageName}}' | ||
$packageSearch = "PeerBlock" | ||
$installerType = 'exe' | ||
$silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' | ||
$validExitCodes = @(0) | ||
Get-ItemProperty -Path @( 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' ) ` | ||
-ErrorAction:SilentlyContinue ` | ||
| Where-Object { $_.DisplayName -like "$packageSearch*" } ` | ||
| ForEach-Object { Uninstall-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-SilentArgs "$($silentArgs)" ` | ||
-File "$($_.UninstallString)" ` | ||
-ValidExitCodes $validExitCodes } |
19 changes: 11 additions & 8 deletions
19
automatic/projectlibre.install/tools/chocolateyInstall.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
$packageName = '{{PackageName}}' | ||
# due to limitations of Ketarin/chocopkgup when using repos like sf.net: | ||
$url = '{{DownloadUrlx64}}' | ||
$checksum = '{{Checksum}}' | ||
$checksumType = 'sha1' | ||
$installerType = 'msi' | ||
$partialInstallArgs = '/quiet /qn /norestart TARGETDIR=' | ||
$is64bit = (Get-WmiObject Win32_Processor).AddressWidth -eq 64 | ||
if ($is64bit) {$installPath = ${Env:ProgramFiles(x86)}} else {$installPath = $Env:ProgramFiles} | ||
if (Get-ProcessorBits 64) { | ||
$installPath = ${Env:ProgramFiles(x86)} | ||
} else { | ||
$installPath = $Env:ProgramFiles | ||
} | ||
$installArgs = $($partialInstallArgs + '"' + $installPath + '"') | ||
$url = '{{DownloadUrlx64}}' | ||
$checksum = '{{Checksumx64}}' | ||
$checksumType = 'sha1' | ||
$validExitCodes = @(0) | ||
|
||
Install-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-Url "$url" ` | ||
-SilentArgs "$silentArgs" ` | ||
-Url "$url" ` | ||
-ValidExitCodes $validExitCodes ` | ||
-Checksum "$checksum" ` | ||
-ChecksumType "$checksumType" | ||
-ChecksumType "$checksumType" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
try { | ||
$packageName = '{{PackageName}}' | ||
$fileType = 'exe' | ||
$silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART' | ||
$validExitCodes = @(0) | ||
$processor = Get-WmiObject Win32_Processor | ||
$is64bit = $processor.AddressWidth -eq 64 | ||
if ($is64bit) { | ||
$unPath = 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' | ||
} else { | ||
$unPath = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' | ||
} | ||
$unFile = (Get-ItemProperty $unPath\* | Where-Object {$_.DisplayName -like "$packageName*"}).UninstallString | ||
Uninstall-ChocolateyPackage "$packageName" "$fileType" "$silentArgs" "$unFile" -validExitCodes "$validExitCodes" | ||
} catch { | ||
throw $_.Exception | ||
} | ||
$packageName = '{{PackageName}}' | ||
$packageSearch = "QuiteRSS" | ||
$installerType = 'exe' | ||
$silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' | ||
$validExitCodes = @(0) | ||
Get-ItemProperty -Path @( 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', | ||
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' ) ` | ||
-ErrorAction:SilentlyContinue ` | ||
| Where-Object { $_.DisplayName -like "$packageSearch*" } ` | ||
| ForEach-Object { Uninstall-ChocolateyPackage -PackageName "$packageName" ` | ||
-FileType "$installerType" ` | ||
-SilentArgs "$($silentArgs)" ` | ||
-File "$($_.UninstallString)" ` | ||
-ValidExitCodes $validExitCodes } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters