Executing 32bit and 64bit mshta.exe (bypass default handler)

隐身守侯 提交于 2019-12-10 10:04:49

问题


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.


回答1:


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:

Rem run32.bat
%WinDir%\SysWOW64\mshta.exe c:\page.hta

Rem run64.bat
%WinDir%\System32\mshta.exe c:\page.hta

Here is what I get:




回答2:


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.



来源:https://stackoverflow.com/questions/5331193/executing-32bit-and-64bit-mshta-exe-bypass-default-handler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!