4

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

TJR
  • 3,617
  • 8
  • 38
  • 41

4 Answers4

3

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.

earlNameless
  • 2,878
  • 20
  • 25
  • You will also need to enable script debugging on IE from the Tools => Internet Options => Advanced Tab => Browsing. – cup Dec 20 '20 at 05:32
2

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.

TJR
  • 3,617
  • 8
  • 38
  • 41
1

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

Farrukh Waheed
  • 2,163
  • 2
  • 29
  • 59
1

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
Jay
  • 3,471
  • 4
  • 35
  • 49