Skip to content

Commit

Permalink
[npcap.vm] Fix npcap never finishing
Browse files Browse the repository at this point in the history
Some times the npcap installation takes longer than the ahk script
expects. The script finishes with error code and without closing the
installation window and the package installation script waits
indefinitely for the process to finish. This prevents FLARE-VM
installation to continue. If you close it manually if fails (because of
the error return code).

To fix the issue, the following two steps are needed:
- Increase waiting time in the ahk script
- Set a maximum time to wait for the process in the package installation script
  • Loading branch information
Ana06 committed Dec 16, 2024
1 parent ecac581 commit da09d88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/npcap.vm/npcap.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>npcap.vm</id>
<version>1.80</version>
<version>1.80.20241216</version>
<authors>Nmap Project</authors>
<description>Npcap is an architecture for packet capture and network analysis for Windows operating systems, consisting of a software library and a network driver.</description>
<dependencies>
Expand Down
7 changes: 5 additions & 2 deletions packages/npcap.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ try {
VM-Assert-Path $packageArgs.fileFullPath

$ahkInstaller = Join-Path $(Split-Path $MyInvocation.MyCommand.Definition) "install.ahk" -Resolve
$rc = (Start-Process -FilePath $ahkInstaller -ArgumentList $packageArgs.fileFullPath -PassThru -Wait).ExitCode
if ($rc -eq 1) {
$process = Start-Process -FilePath $ahkInstaller -ArgumentList $packageArgs.fileFullPath -PassThru
# Wait for the AutoHotKey script to finish. We need a max time as if something goes wrong
# (for example the installation takes longer than exception), it will never finish.
$process.WaitForExit(60000)
if ($process.ExitCode -eq 1) {
throw "AutoHotKey returned a failure exit code ($rc) for: ${Env:ChocolateyPackageName}"
} else {
VM-Assert-Path $(Join-Path ${Env:PROGRAMFILES} "Npcap\npcap.cat")
Expand Down
8 changes: 4 additions & 4 deletions packages/npcap.vm/tools/install.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WinWait, %installerTitle%,,20
WinActivate

exitCode := 1
loop, 20
loop, 50
{
if WinExist(installerTitle, "i).*license agreement.*")
{
Expand All @@ -27,7 +27,7 @@ loop, 20
}
if WinExist(installerTitle, "i).*installing.*")
{
Sleep, 5000
Sleep, 10000
}
if WinExist(installerTitle, "i).*installation complete.*")
{
Expand All @@ -51,6 +51,6 @@ loop, 20
exitCode := 0
break
}
Sleep 1000
Sleep, 1000
}
ExitApp %exitCode%
ExitApp %exitCode%

0 comments on commit da09d88

Please sign in to comment.