DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute .js file through cmd on DIAdem

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?

0 Kudos
Message 1 of 2
(2,548 Views)

Hi hysde, 

 

 

I'm not familar the "node" command but I'm assuming it's from: https://nodejs.org ? A couple of suggestions:

 

  1. Have you tried using "runas" for elevated permissions?
  2. Do you need to open cmd.exe in the correct path? see: https://superuser.com/questions/834319/node-js-wont-run-from-cmd-exe-in-windows-7-x64

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

0 Kudos
Message 2 of 2
(2,509 Views)