首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ResGen.exe的VBscript日志响应

ResGen.exe的VBscript日志响应
EN

Stack Overflow用户
提问于 2012-04-12 20:28:14
回答 1查看 229关注 0票数 0

我在一个VBScript上工作,用ResGen.exe生成资源文件,需要收集ResGen的错误信息并将其写入文件中,我已经控制了文件写入的部分(在这里显示的脚本中没有,但我知道如何做)

代码语言:javascript
复制
'' 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

在objShell.Run行之后,我需要放入什么来保存此命令的响应?我试着在命令后添加“>> "C:\log.txt”“,但是没有生成资源文件,只将响应保存在txt文件中。

希望我的解释是正确的。

提前感谢!

EN

回答 1

Stack Overflow用户

发布于 2012-05-07 22:03:33

您可以使用Exec方法来获取WshScriptExec对象,并使用它的StdOut来获取命令的响应,如下图所示:

代码语言:javascript
复制
'' 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 
    '***************************************
    Set oExec = objShell.Exec(execommand)
    Do While oExec.Status = 0
        WScript.Sleep 1000
    Loop
    WScript.Echo oExec.StdOut.ReadLine
    '***************************************
Loop
objFSO.Close
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10123577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档