mvandenberg2
12 years agoOccasional Contributor
Jscript - Execute DOS command
Hi,
I'm trying to execute a dos command in Jscript, but I keep getting "The system cannot find the file specified"
I'm sure it has something to do with qoutes. I've tried every combination I could think of, but I can't get it right.
I want to get the list of files in a directory and write it to a file. If there is a better way of doing it then I'll try that as well.
This is my code:
I'm trying to execute a dos command in Jscript, but I keep getting "The system cannot find the file specified"
I'm sure it has something to do with qoutes. I've tried every combination I could think of, but I can't get it right.
I want to get the list of files in a directory and write it to a file. If there is a better way of doing it then I'll try that as well.
This is my code:
var command = "dir /b c:\ProgramData\testfolder1\testfolder2 >D:\Automation\Data\testdata\testfile.csv"
Sys.OleObject("Wscript.Shell").Exec(command)
- var command = "cmd /c dir /b c:\ProgramData\testfolder1\testfolder2 >D:\Automation\Data\testdata\testfile.csv"