通过 Wscript.Shell Run 从 HTA 调用 MSG.exe [英] Calling MSG.exe from an HTA via Wscript.Shell Run

查看:26
本文介绍了通过 Wscript.Shell Run 从 HTA 调用 MSG.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我做什么,我都无法让它发挥作用.即使我在 BAT 文件中删除msg/server:"语法并从 Shell.Run 调用它,它仍然说'msg' 不是内部或外部命令、可运行的程序或批处理文件."

I cannot get this to work no matter what I do. Even if I drop the "msg /server: " syntax in a BAT file and call it from the Shell.Run, it still says "'msg' is not recognized as an internal or external command, operable program or batch file."

我也试过msg.exe"和c:\windows\system32\msg.exe".所有表单都可以从 CMD 控制台直接输入和 VBScript 或 CMD/BAT 脚本中正常工作,但不能从 HTA 中正常工作.这是设计使然"的安全功能吗?反正有这个吗?

I've also tried "msg.exe" and "c:\windows\system32\msg.exe". All forms work fine from a CMD console direct entry, and from a VBScript or CMD/BAT script, but not from an HTA. Is that a security feature "by design"? Is there anyway around this?

推荐答案

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

For backward compatibility, 64-bit Windows ships with two versions of MSHTA.exe:

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

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

The behavior you describe is one of the curiosities about the 64-bit MSHTA.exe, it can't invoke 32-bit applications like MSG.exe. Note that the 64-bit command prompt at c:\windows\SysWOW64\cmd.exe will also fail to find MSG.exe.

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

To fix this, you can associate .hta files with the 32-bit MSHTA.exe, or create a simple batch file to start your HTA, START_MSG.cmd:

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

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

I've tested the HTA below with both the 64 and 32-bit versions of MSHTA.exe. The 64-bit version raises a "file not found" error, but the 32-bit version works.

<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> 

这篇关于通过 Wscript.Shell Run 从 HTA 调用 MSG.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆