I have a PowerShell script that I need to run from a VBScript and I need the VBScript to wait on the PowerShell to finish (but the two don't need to communicate at all). Here's code that will execute the powershell, but the VBScript doesn't wait:
Set objShell = (CreateObject("Wscript.shell"))
objShell.Run ("powershell -noexit -file e:\powershell\vb_to_powershell_test.ps1")
MsgBox("Powershell execution complete")
This script will pop up with "Powershell execution complete" instantly, while the PowerShell is still running.
Apparently there is a True
flag I could add that forces VB to wait. Like so, maybe:
objShell.Run ("powershell -noexit -file e:\powershell\vb_to_powershell_test.ps1", True)
That isn't working for me, as the script always complains about "cannot use parenthesis when calling a sub", which is a whole thing.
I suspect this is a VisualBasic vs. VB.NET issue, but I'm stuck with VisualBasic here.
What am I doing wrong?