I need to debug several VBS files that make up a HTA application.
I've searched the web and couldn't find the exact QA. This one about How to run multiple batch files with single External Tool in Visual Studio and How to debug IE9 HTA? which a silver bullet hasn't been found.
This is where I'm stuck, I debug main.vbs and it references a class cutils
which is in the file utils.vbs. And when I step over this line to instantiate cutils I get an error:
Microsoft VBScript runtime error: Variable is undefined: 'cutil'
So I tried a few External Tool Arguments like comma separated files:
//nologo //X "$(ItemPath), $(ItemDir)utils.vbs"
But that doesn't work. Is that possible, to specify multiple files?
Otherwise apart from copying all the classes into one file how can I debug the VBS files in Visual Studio? I've tried to attach VS debugger to mshta.exe however it does NOT get into debug mode, even with the standard debugger
keyword doesn't halt code control:
function clickButton()
debugger
So I am after a way to debug multiple VBA files with cscript.exe or even better attach to a mshta process to step through the code with debugger attached.
Update 1:
Following this answer https://stackoverflow.com/a/316491/495455 I tried creating a wsf file with all the references and using cscript.exe to debug:
<job id="IncludeExample">
<script language="VBScript" src="main.vbs"/>
<script language="VBScript" src="utils.vbs"/>
</job>
This starts off on main.vbs however it still fails to find the cutils class in utils.vbs:
Update 2:
So I renamed the .hta file extension to .html and that allowed me to open IE's Developer tools. For some reason pressing F12 in a HTA application doesn't allow you to use the Dev Tools.
When I do this, debugging is painful, the debugger can seem to find utils.vbs however, when I call the activate function in main.vbs it says it can't be found. Or more specifically main is not defined.