开发者

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

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开发者_如何学JAVA
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.


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:

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜