2012-11-06 18 views
2

有人能告訴我爲什麼重定向到一個文件在我的HTA程序中不起作用嗎?它包含以下內容:使用HTA應用程序將shell應用程序輸出重定向到一個文件

Set objShell = CreateObject("Shell.Application") 
objShell.ShellExecute "md5sums.exe", "tarball.tar > .\md5sum.log", , , NORMAL_WINDOW 

當我跑我上面的兩行HTA程序沒有重定向它工作正常。但第二次我添加「> \ md5sum.log。」 md5sums.exe吐出以下錯誤:

Unable to read file/directory .\md5sum.log 

,這意味着它忽視了重定向符號,並試圖採取不存在的md5sum的校驗.log文件。

md5sums.exe只是一個外部校驗和程序。當我運行在命令行下,它工作正常:

md5sums.exe tarball.tar > .\md5sum.log 

,管道爲tarball.tar到md5sum.log文件的校驗符合市場預期。

我在整個Interwebs中搜索高低,沒有找到解決方案。我非常感謝任何人都可以提供的幫助。

回答

1

終於明白了!如果有人遇到這種情況:

shellCmd = "cmd /c md5sums.exe ""tarball.tar"" > ""md5sum.log""" 
Set shell = CreateObject("WScript.Shell") 
shell.Run shellCmd 
相關問題