The following works fine:
VBScript
Script = "C:\Users\bob\Downloads\Logon scripts\Script.ps1"
Dim oSHELL
Set oSHELL = CreateObject("WScript.Shell")
oSHELL.Run "powershell.exe -ExecutionPolicy Bypass -NoLogo -File ""C:\Users\bob\Downloads\Logon scripts\Script.ps1""", 0, True
Set oSHELL = Nothing
When I'm trying to put the path to the script in a variabla, it's not working:
oSHELL.Run "powershell.exe -ExecutionPolicy Bypass -NoLogo -File ""Script""", 0, True
oSHELL.Run "powershell.exe -ExecutionPolicy Bypass -NoLogo -File""" & Script & """", 0, True
Script.ps1
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.MessageBox]::Show("Test MessageBox", "Information")
How is it possible to have WScript use the variable correctly?
-File. Apart from that it should work fine.