I'm working on a VBScript to generate resource files with ResGen.exe and need to collect the error message of ResGen and write this in a file, have controlled the part of file write (is not present in the script show here but i know how to do it)
'' Folder that contains the files
folderpath = "C:\Users\Administrator\Desktop\Author\author\"
'Destination folder from generated files
destfolder = "C:\Users\Administrator\Desktop\Author\author\"
'Folder contains the text file with list of files names
listfolder = "C:\Users\Administrator\Desktop\Author\"
listfile = listfolder + "list.txt"
logfile = listfolder + "log.txt"
resgen = "ResGen.exe /compile"
Set objShell = CreateObject("WScript.Shell")
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Wscript.echo listfile
Set objFile = objFSO.OpenTextFile(listfile, ForReading)
Wscript.echo "Reading file"
Do While objFile.AtEndOfStream = False
strLine = objFile.ReadLine
cmdexec = Chr(34) + folderpath + strLine + "resx" + Chr(34) + " " + Chr(34) + destfolder + strLine + "resources" + Chr(34)
execommand = resgen + " " + cmdexec
objShell.Run execommand,1,TRUE
Loop
objFSO.Close
After objShell.Run line, what I need to put to save the response of this command? I've tried adding " >> "C:\log.txt" " after the command but with this the resource files are not generated, only save the response in txt file.
Hope I have explained correctly.
Thanks in advance!
You can use the "Exec" method to get the WshScriptExec object, and use it's StdOut to get the response of the command, as showed below: