执行 32 位和 64 位 mshta.exe(绕过默认处理程序)
我希望能够在 32 位和 64 位版本的 mshta.exe 中启动 page.hta。
创建文件 c:\page.hta
<body onclick="if(confirm('Close? (onclick)')){self.close();}">
<h1>Test Page</h1>
<script type="text/javascript">
var elem = [
"UserAgent="+window.navigator.userAgent,
"Platform="+window.navigator.platform
];
var taBegin = "<textarea style='width:100%' rows='"+((elem.length+1)*1.5)+"'>";
var taEnd = "</textarea>";
document.write(taBegin+elem.join("\n")+taEnd);
</script>
</body>
现在这是尝试以不同方式加载页面的批处理文件。
@echo off
rem Launch 32bit
c:\Windows\SysWOW64\mshta.exe c:\page.hta
rem Launch 64bit
c:\Windows\System32\mshta.exe c:\page.hta
另一件有趣的事情是,尝试将 .hta 文件的默认处理程序更改为记事本。如果执行前面的命令,它会启动记事本。看来 mshta 有一些逻辑仅通过默认处理程序启动 .hta。
使用指定为默认处理程序的任何命令。
I'd like to be able to launch a page.hta in 32bit and 64bit versions of the mshta.exe.
Create the file c:\page.hta
<body onclick="if(confirm('Close? (onclick)')){self.close();}">
<h1>Test Page</h1>
<script type="text/javascript">
var elem = [
"UserAgent="+window.navigator.userAgent,
"Platform="+window.navigator.platform
];
var taBegin = "<textarea style='width:100%' rows='"+((elem.length+1)*1.5)+"'>";
var taEnd = "</textarea>";
document.write(taBegin+elem.join("\n")+taEnd);
</script>
</body>
Now here is the batch file to attemp to load the page differently.
@echo off
rem Launch 32bit
c:\Windows\SysWOW64\mshta.exe c:\page.hta
rem Launch 64bit
c:\Windows\System32\mshta.exe c:\page.hta
Another interesting thing, try changing the default handler to notepad for .hta files. If you execute the previous commands, and it launches notepad. It appears that mshta has some logic that only launches the .hta via the default handler.
Whatever command is specified as the default handler is used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这是操作系统版本问题(?)我无法判断,因为您的测试在我的 XP x64 上按预期运行。
[编辑]我运行的代码:
这是我得到的:
Maybe it's a OS version issue (?) I can't tell, as your test run as expected on my XP x64.
[EDIT] The code I run:
Here is what I get:
system32/systemwow64 文件夹是“虚拟”的,因为它们的内容由操作系统根据访问应用程序的位数决定 - 在您的情况下 cmd.exe 可能是 64 位版本,因此它将始终启动 64 位 - 的 mshta.exe 版本
用于在 32 位中启动命令提示符 请参阅 http://astatalk .com/thread/7382/0/How_to_Open_and_Run_32-bit_Command_Prompt_in_x64_Windows/
它也可以帮助使用 SysNative 而不是 system32 并查看 mshta.exe 的行为然后...
mshata.exe 似乎只是使用标准.hta 的设置,这样无论您启动 32 位还是 64 位版本的 mshta.exe 都可能无关紧要 - 您可以尝试将 .hta 与浏览器的 32 位版本关联起来...
如果您想绕过它,那么您可以直接在批处理文件中调用浏览器(32 位或 64 位)...
编辑 - 根据评论:
对于 64 位执行,您可以使用“C:\Program Files \Internet Explorer\iexplore.exe”在批处理文件中并且
对于 32 位执行,您使用“C:\Program Files (x86)\Internet Explorer\iexplore.exe”。
根据您的系统,您需要打开具有所需位数的命令 shell - 请参阅上面的链接。
the system32/systemwow64 folders are "virtual" in the sense that their content is determined by the OS depending on the bitness of the accessing application - in your case cmd.exe is probably the 64 Bit version so it will always start the 64 Bit-version of the mshta.exe
for starting a command prompt in 32 bit see http://astatalk.com/thread/7382/0/How_to_Open_and_Run_32-bit_Command_Prompt_in_x64_Windows/
it could also help to use SysNative instead of system32 and see how mshta.exe acts then...
mshata.exe seems to just use the standard settings for .hta so that it propbably won't matter whether you start the 32bit or the 64bit version of mshta.exe - you can try by associating .hta with 32 bit sersion of your browser...
IF you want to bypass that then you could just call the browser (32 bit or 64 bit) directly in your batch file...
EDIT - as per comment:
For 64 Bit execution you could use "C:\Program Files\Internet Explorer\iexplore.exe" in your batch file and
for 32 Bit execution you use "C:\Program Files (x86)\Internet Explorer\iexplore.exe".
Depending on youd system you need to open up a command shell with the desired bitness - see the link above.