Skip to content

Commit

Permalink
Merge pull request #718 from mandiant/psnotify-fix
Browse files Browse the repository at this point in the history
Clean up psnotify chocoinstall
  • Loading branch information
Ana06 authored Oct 31, 2023
2 parents b01509e + 08e0e43 commit 4d11dd5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/psnotify.vm/psnotify.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>psnotify.vm</id>
<version>0.2.4</version>
<version>0.2.4.20231020</version>
<authors>alphillips-lab</authors>
<description>A POC tool to fight .NET anti-dumping tricks.</description>
<dependencies>
Expand Down
47 changes: 19 additions & 28 deletions packages/psnotify.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,29 @@ try {

$unzipLocation = 'C:\' # psnotify has a requirement of being located in 'C:\psnotify'
$toolDir = Join-Path $unzipLocation $toolName
try {
$toolDir = Join-Path $unzipLocation $toolName
$shortcutDir = Join-Path ${Env:TOOL_LIST_DIR} $category
$shortcutDir = Join-Path ${Env:TOOL_LIST_DIR} $category

# Remove files from previous zips for upgrade
VM-Remove-PreviousZipPackage ${Env:chocolateyPackageFolder}
# Remove files from previous zips for upgrade
VM-Remove-PreviousZipPackage ${Env:chocolateyPackageFolder}

# Download and unzip
$packageArgs = @{
packageName = ${Env:ChocolateyPackageName}
unzipLocation = $unzipLocation
url = $zipUrl
checksum = $zipSha256
checksumType = 'sha256'
url64bit = $zipUrl_64
checksum64 = $zipSha256_64
}
Install-ChocolateyZipPackage @packageArgs
VM-Assert-Path $toolDir
$executablePath = Join-Path $toolDir "$toolName.exe" -Resolve
$shortcut = Join-Path $shortcutDir "$toolName.lnk"

$executableDir = $toolDir
Install-ChocolateyShortcut -shortcutFilePath $shortcut -targetPath $executablePath -WorkingDirectory $executableDir
VM-Assert-Path $shortcut

Install-BinFile -Name $toolName -Path $executablePath
return $executablePath
} catch {
VM-Write-Log-Exception $_
# Download and unzip
$packageArgs = @{
packageName = ${Env:ChocolateyPackageName}
unzipLocation = $unzipLocation
url = $zipUrl
checksum = $zipSha256
checksumType = 'sha256'
url64bit = $zipUrl_64
checksum64 = $zipSha256_64
}
Install-ChocolateyZipPackage @packageArgs
VM-Assert-Path $toolDir
$executablePath = Join-Path $toolDir "$toolName.exe" -Resolve
$shortcut = Join-Path $shortcutDir "$toolName.lnk"

$executableDir = $toolDir
Install-ChocolateyShortcut -shortcutFilePath $shortcut -targetPath $executablePath -WorkingDirectory $executableDir
VM-Assert-Path $shortcut
} catch {
VM-Write-Log-Exception $_
}
5 changes: 1 addition & 4 deletions packages/psnotify.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ $toolDir = 'C:\psnotify'
Remove-Item $toolDir -Recurse -Force -ea 0 | Out-Null

# Remove tool shortcut
VM-Remove-Tool-Shortcut $toolName $category

# Uninstall binary
Uninstall-BinFile -Name $toolName
VM-Remove-Tool-Shortcut $toolName $category

0 comments on commit 4d11dd5

Please sign in to comment.