I need Excel VBA to call another script language using shell. Ideally, also returning its output, but if that is hard to do, just to execute that other script and tell the user in a pop-up MessageBox where to get the output from and paste it into the Excel file.
I tried several ways, including (I took out some full file names):
pscmd = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy Bypass -File ......\.....ps1"
or
Shell("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ""........ps1""", vbNormalFocus)
- with full path to powershell or not
or
Shell("ruby.exe ""C:\testsoft\test.rb", "C:\testsoft\tst.txt""", vbNormalFocus)
or
Shell("powershell -ExecutionPolicy Bypass "".....ps1 -input """ & pathVariable & """", 1)
or
Sub RunPowershellScript()
strCommand = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy Bypass -File ""C:\testsoft\mdruby-nolog.ps1"""
Set wshShell = CreateObject("WScript.Shell")
Set WshShellExec = wshShell.Exec(strCommand)
strOutput = WshShellExec.StdOut.ReadAll
MsgBox strOutput
End Sub
but all to no avail.
It does not work at all with running a ruby script or powershell script or opening cmd.
For example, calling up some programs that I tested work though:
strCommand = "ping.exe 127.0.0.1"
strCommand = "notepad.exe" ' works even with specifying a file to open
strCommand = "calc.exe"
My powershell or ruby scripts shall calculate MD5 checksums of PDFs created from Excel using VBA. They work on their own, just fine.
Is there an easy way?