04-20-2018 03:41 AM
Executing a python file works and returns an output as shown in the code.
cmdVar = getCommandOutput("cmd.exe /c python C:\Temp\Hello.py") MsgBox cmdVar 'Returns "Hello" Function getCommandOutput(theCommand) Dim objShell, objCmdExec Set objShell = CreateObject("WScript.Shell") Set objCmdExec = objshell.exec(thecommand) getCommandOutput = objCmdExec.StdOut.ReadAll End Function
However when trying to execute a node .js file by modifying the cmd command slightly it does not work even though the command actually works on command prompt.
cmdVar = getCommandOutput("cmd.exe /c node C:\Temp\Hello.js")
How do I fix this issue?
04-23-2018 07:23 AM
Hi hysde,
I'm not familar the "node" command but I'm assuming it's from: https://nodejs.org ? A couple of suggestions:
Workaround?
One of the most common ways this functionality is achieved is to redirect the output to a file and then read from the file. Check out this post for an example.
hope this helps,
Rebecca