gpt4 book ai didi

shell - 通过 Wscript.Shell Run 从 HTA 调用 MSG.exe

转载 作者:行者123 更新时间:2023-12-04 03:06:43 26 4
gpt4 key购买 nike

无论我做什么,我都无法让它工作。即使我在 BAT 文件中删除“msg/server:”语法并从 Shell.Run 中调用它,它仍然说“'msg' 未被识别为内部或外部命令、可运行程序或批处理文件。”

我也试过“msg.exe”和“c:\windows\system32\msg.exe”。所有表单在 CMD 控制台直接输入、VBScript 或 CMD/BAT 脚本中都能正常工作,但在 HTA 中却不行。这是“设计”的安全功能吗?有什么办法吗?

最佳答案

为了向后兼容,64 位 Windows 附带两个版本的 MSHTA.exe:

  C:\Windows\SysWOW64\mshta.exe and 
C:\Windows\System32\mshta.exe

您描述的行为是对 64 位 MSHTA.exe 的好奇之一,它无法调用 MSG.exe 等 32 位应用程序。请注意,位于 c:\windows\SysWOW64\cmd.exe 的 64 位命令提示符也将无法找到 MSG.exe。

要修复此问题,您可以将 .hta 文件与 32 位 MSHTA.exe 相关联,或者创建一个简单的批处理文件来启动您的 HTA,START_MSG.cmd:

START C:\Windows\System32\mshta.exe C:\YOUR_PATH\MSG.hta

我已经使用 64 位和 32 位版本的 MSHTA.exe 测试了下面的 HTA。 64 位版本引发“找不到文件”错误,但 32 位版本有效。

<script language="Javascript">
var E, LineWriteTimerID
function execWithStatus(cmdLine){
E = new ActiveXObject("WScript.Shell").Exec(cmdLine);
LineWriteTimerID = window.setInterval("writeOutLine()",100);
E.StdIn.Close();
}
function writeOutLine(){
if(E.StdOut.AtEndOfStream) window.clearTimeout(LineWriteTimerID);
if(!E.StdErr.AtEndOfStream) txtResults.value += "ERROR: " + E.StdErr.ReadAll() + "\n";
if(!E.StdOut.AtEndOfStream) txtResults.value += E.StdOut.ReadLine() + "\n";
}
</script>
<textarea id=txtCmd style="width:90%" rows=1>MSG.exe</textarea>
<button onclick="execWithStatus(txtCmd.value)">Run</button>
<br><textarea id=txtResults style="width:100%" rows=20></textarea>

关于shell - 通过 Wscript.Shell Run 从 HTA 调用 MSG.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9833604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com