当来自 HTA 的 运行 时,bWaitOnReturn 对 mstsc.exe 没有影响
bWaitOnReturn has no effect on mstsc.exe when run from HTA
在 VBScript 中,WScript.Shell.Run
方法有 three arguments,其中第三个是布尔值,指定程序是否应等待新生成的进程完成后再继续。
我无法使此行为与 mstsc.exe
(Windows 中的远程桌面连接程序)一起正常工作。
如果我将以下文件保存为 test.vbs
并使用 cscript test.vbs
执行它,它会按预期工作。
Set obj = CreateObject("WScript.Shell")
Call obj.Run("notepad.exe", 1, true)
MsgBox "You just closed notepad."
Call obj.Run("mstsc.exe", 1, true)
MsgBox "Remote desktop just closed."
但是,如果我尝试从 HTA 文件执行相同的代码,它无法正常工作 -- 相反,运行 mstsc.exe
之后的消息框会立即出现,而不是等待。
<html>
<head>
<script language="VBScript">
Sub RunProgram
Set obj = CreateObject("WScript.Shell")
Call obj.Run("notepad.exe", 1, true)
MsgBox "You just closed notepad."
Call obj.Run("mstsc.exe", 1, true)
MsgBox "Remote desktop is still open!"
End Sub
</script>
</head>
</body>
<body onload=RunProgram>
</html>
知道为什么会发生这种情况以及如何解决它吗?
编辑:我已经在 Windows 10 和 7 上测试过了。
使用 64 位版本的 mstsc。 c:\windows\sysnative\mstsc.exe
Sysnative
允许 32 位程序访问 System32
目录。尝试访问 C:\windows\system32
的 32 位程序被重定向到 c:\windows\syswow64
.
来自我的第一条评论。
我在 Windows 10 上得到了同样的结果。我怀疑这与将 HTA 设置为 运行 作为 32 位有关,但即使将 mstsc 更改为 32 位版本也没有任何区别
在 VBScript 中,WScript.Shell.Run
方法有 three arguments,其中第三个是布尔值,指定程序是否应等待新生成的进程完成后再继续。
我无法使此行为与 mstsc.exe
(Windows 中的远程桌面连接程序)一起正常工作。
如果我将以下文件保存为 test.vbs
并使用 cscript test.vbs
执行它,它会按预期工作。
Set obj = CreateObject("WScript.Shell")
Call obj.Run("notepad.exe", 1, true)
MsgBox "You just closed notepad."
Call obj.Run("mstsc.exe", 1, true)
MsgBox "Remote desktop just closed."
但是,如果我尝试从 HTA 文件执行相同的代码,它无法正常工作 -- 相反,运行 mstsc.exe
之后的消息框会立即出现,而不是等待。
<html>
<head>
<script language="VBScript">
Sub RunProgram
Set obj = CreateObject("WScript.Shell")
Call obj.Run("notepad.exe", 1, true)
MsgBox "You just closed notepad."
Call obj.Run("mstsc.exe", 1, true)
MsgBox "Remote desktop is still open!"
End Sub
</script>
</head>
</body>
<body onload=RunProgram>
</html>
知道为什么会发生这种情况以及如何解决它吗?
编辑:我已经在 Windows 10 和 7 上测试过了。
使用 64 位版本的 mstsc。 c:\windows\sysnative\mstsc.exe
Sysnative
允许 32 位程序访问 System32
目录。尝试访问 C:\windows\system32
的 32 位程序被重定向到 c:\windows\syswow64
.
来自我的第一条评论。
我在 Windows 10 上得到了同样的结果。我怀疑这与将 HTA 设置为 运行 作为 32 位有关,但即使将 mstsc 更改为 32 位版本也没有任何区别