'How to redirect standard/error output to file whil using Run command?
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?
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chad Nouis |
