I get this error:
Image
When i try to run this code:
strComputer = "server01"
strCommand = "powershell.exe -NoLogo -Command Start-Service -InputObject $(Get-Service -Computer " & strComputer & " -Name " & strService & ")"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objExec = WshShell.Run(strCommand,0,True)
I want to run strCommand in an hidden window. This works the code ran through and do what it should do but this error occure and this is really bad.
.Run() – as opposed to .Exec() – returns an error code (not an object). So you must not use
but