0

I am using following code:

cmd = """" & "C:/node/executable/path/node.exe" & """" & " " & """" & "C:/path/to/script.js" & """" & " > " & """" & "C:/path/to/output.txt" & """"
WshShell.Run cmd, 0, False

cmd looks like this:

"C:/node/executable/path/node.exe" "C:/path/to/script.js" > "C:/path/to/output.txt"

This script works (it starts in background) but output is never redirected to a file (file does not appear). What I am doing wrong?

1 Answer 1

2

The redirection operator (">") is a cmd.exe shell feature. The node.exe process needs to be launched by a cmd.exe process:

Set WshShell = WScript.CreateObject("WScript.Shell")

cmd = "cmd.exe /c ""C:\node\executable\path\node.exe""  ""C:\path\to\script.js"" > ""C:\path\to\output.txt"""

WshShell.Run cmd, 0, False

Not the answer you're looking for? Browse other questions tagged or ask your own question.