2

有人能告诉我为什么重定向到文件在我的 HTA 程序中不起作用吗?它包含以下内容:

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 中到处搜索,但没有找到解决方案。我非常感谢任何人可以提供的任何帮助。

4

1 回答 1

1

终于想通了!万一有人遇到这种情况:

shellCmd = "cmd /c md5sums.exe ""tarball.tar"" > ""md5sum.log"""
Set shell = CreateObject("WScript.Shell")
shell.Run shellCmd
于 2012-11-07T22:40:58.237 回答