I am working on a menu that calls PowerShell scripts with wscript.shell
and ActiveX. I am passing three variables to wshshell.Run
:
scriptID
, which is the name of a ps1 file,vmName
, which is the name of the virtual machine the script will act on, andcheckstate
, which is the state of the checkbox associated with the menu item.
Here is my current non-working code:
WshShell = new ActiveXObject("Wscript.Shell");
WshShell.Run("powershell.exe -file " & scriptID & " " & vmName & " " & checkstate, 7, true);
This always produces an error stating "The system cannot find the file specified."
I have tried following the syntax mentioned here and here with no luck. Both seemed promising but produce the same error I have above.
I tested taking the variables out and just running:
WshShell.Run("powershell.exe -file test.ps1", 7, true)
which works, but
WshShell.Run("powershell.exe -file " & "test.ps1", 7, true)
fails.