/build/static/layout/Breadcrumb_cap_w.png

calling vbscript in powershell

Hi,

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




0 Comments   [ + ] Show comments

Answers (1)

Posted by: rileyz 8 years ago
Red Belt
0
You're doing it wrong.

Try this
& 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.

$command ="`"$Path\Uninstall.vbs`""

Comments:
  • Thank you ... This did not work either.. - shamu 8 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ