Hey i want to run from an vbs script a powershell commando. Something like start powershell.exe and enter a specific command like Restart-Service. I thought something similar to this could work:
strCommand = "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -command Restart-Service [service name]"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objExec = WshShell.Exec(strCommand)
Has someone an idea how can i manage this?
1) store your powershell command as powershell script.
2) Use the vbs to run the powershell
Set objShell = CreateObject("Wscript.Shell")
objShell.Run("powershell.exe -noexit c:\scripts\test.ps1")
Try this:
powershell -command '& {command to run}'
/G
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With