calling vbscript in powershell
I want to run a vbscript from a powereshell. I used cscript.exe and location of vbs. Manually I can get it to work, but through SCCM it does not work. The script basically uninstalls the old version. So manually I see the powershell executes fine by uninstalling but when I try through SCCM nothing happens, it passes through without uninstalling .
$command =" $Path\Uninstall.vbs"
$install = Start-process "CScript.exe" -ArgumentList $Command -Wait -Passthru -Windowstyle hidden
& cscript.exe "$Path\Uninstall.vbs"
If you need the exit code, then you can try this use this
& cscript.exe " $Path\Uninstall.vbs"
$MyExitCode = $LASTEXITCODE
Come to think of this, why don't you just do this in PowerShell??
*I think this might be the issue with your command, if your $Path has spaces, you need to wrap this in quotes or cscript wont eat it correctly. You can use the backtick to escape quotes.