How to debug IE9 HTA?

2020-02-12 13:33发布

Has anyone gotten a debugger attached to mshta.exe after installing IE9? (64bit or WOW64)

4条回答
三岁会撩人
2楼-- · 2020-02-12 13:53

I'm on a Vista x64, so I have to contend with the 32bit/64bit barrier.

HTA

  • c:\windows\system32\mshta.exe (mshta32)
  • c:\windows\syswow64\mshta.exe (mshta64)

Launching

  • "mshta32 foo.hta" may use mshta32 or mshta64 depending on what is associated with HTA
  • the same goes if "mshta64 foo.hta" is used
  • "cmd /C start foo.hta" would have the same affect.

Debugger

  • MS Script Editor (from Office XP/2003) for JS debugging in IE/HTA

Normally I would use the debugger keyword to initiate the launching of the debugger, however with IE9, it doesn't seem to do that anymore. I must launch the debugger first, attach to the mshta.exe process manually (only supports 32bit). Then everything appears to work fine!

EDIT:

With coworkers, different machine have exhibited different behaviors:

  • debugger keyword works fine
  • Connecting to MSHTA.EXE from the debugger doesn't work

I haven't yet found a silver bullet.

查看更多
Juvenile、少年°
3楼-- · 2020-02-12 13:55

Try using 'Stop' statement. This should raise the debugger dialog

查看更多
叛逆
4楼-- · 2020-02-12 14:03

I had the same problem. Finally pieced together how to debug using Visual Studio from two sources

  1. Turn on script debugging through Internet Explorer, as described here and here
  2. Start up Visual Studio. Click on Debug -> Attach to Process
  3. Run the .hta file and select the running process from the Attach to Process dialog
查看更多
走好不送
5楼-- · 2020-02-12 14:13

If you have Visual Studio, go to Tools -> Attach to Process and attach to the MSHTA.EXE process. Then pick Script as the target to debug.

查看更多
登录 后发表回答