I have a .VBS file that I am running. I need to be able to execute a DIR command which lists a number of directories to a text file before moving on with the script and using said text files for other functions. I can confirm that the DIR command works from a command prompt. Here is the code I have currently which doesn't create the file:
SourceRoot = "c:\program files"
strFileType = ".txt"
FileListName = "c:\myfile.txt"
FindFiles SourceRoot, strFileType, FileListName
Set oFSO = CreateObject("Scripting.FileSystemObject")
if oFSO.FileExists(FileListName) then
WScript.Echo "File is there"
WScript.Echo "File is not there"
Sub FindFiles(BaseRoot, FileType, DestFile)
sCommand = "cmd /c dir/s/b '"&BaseRoot&"*"&FileType&"' > '"&DestFile&"'"