Skip to content

Launch npcapwatchdog.ps1 with -NoProfile parameter #529

@ralish

Description

@ralish

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions