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

Launch npcapwatchdog.ps1 with -NoProfile parameter #529

Closed
ralish opened this issue Aug 5, 2021 · 3 comments
Closed

Launch npcapwatchdog.ps1 with -NoProfile parameter #529

ralish opened this issue Aug 5, 2021 · 3 comments

Comments

@ralish
Copy link

ralish commented Aug 5, 2021

During Npcap installation a PowerShell process is launched to run the npcapwatchdog.ps1 script with the following parameters:

powershell.exe -ExecutionPolicy AllSigned -WindowStyle Hidden -NonInteractive -File "C:\Users\<user>\AppData\Local\Temp\nsiXXXX.tmp\npcapwatchdog.ps1" -Instdir "C:\Program Files\Npcap"

I'd suggest adding the -NoProfile parameter to ensure any PowerShell user profile is not executed. At best it slows the installer down by unnecessarily loading any profile settings, but more seriously it can interfere with the installation process and result in erroneous error messages.

My own profile is an example of this: in some scenarios it compiles some C# code via Add-Type. It turns out that when generating the parameters to pass to the C# compiler (csc.exe), PowerShell adds a relative reference to System.dll (to facilitate the automatic using System; statement added to the provided C# code). The PowerShell process is launched in the above created temporary directory and NSIS drops a System.dll there, which gets picked up by the compiler instead of the correct .NET CLR assembly. That results in a bunch of error spew in the installer output due to the failed compilation.

In my case it's harmless but misleading, though more serious interference with the installer is possible. Admittedly it's an edge case, but I can't see any benefit from executing user profiles during install, and -NoProfile should make the installer more deterministic.

@dmiller-nmap
Copy link
Contributor

We'll definitely do that! Npcap is currently supporting Windows 7, which means we have to ensure our scripts and invocation can be used with Powershell 2.0. Do you know if the -NoProfile switch is supported in that version?

@ralish
Copy link
Author

ralish commented Aug 11, 2021

Can confirm that -NoProfile is supported in PowerShell 2.0 from a fresh install of Windows 7 SP1 with no further updates.

@dmiller-nmap
Copy link
Contributor

Fixed in Npcap 1.55 release. We also changed the npcapwatchdog task creation from a signed script to a one-line command to avoid the overhead of digital signature validation, which should speed up the install process as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants