i am trying to run a few powershellscript from vba excel , it was working fine . But now am getting error of system can not find the file .

Sub Button1_Click()
strCommand = "Powershell -File ""C:\Users\Sagar.Patro\Documents\Powershell\xyz.ps1"""
    Set WshShell = CreateObject("WScript.Shell")
    Set WshShellExec = WshShell.Exec(strCommand)  *<- debug highlighting this line*
    strOutput = WshShellExec.StdOut.ReadAll
End Sub
  • 1
    What changed when it stopped working? Did you move the code to a different machine, or were there software updates? – AFH Dec 16 '18 at 14:22
  • 1
    Is it possible that C:\Windows\System32 is no longer in your PATH? – harrymc Dec 16 '18 at 15:07
  • what's the output of where powershell ? – shawn Dec 29 '18 at 20:36

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.