Debugging VBScript
The Visual Studio programmer has the convenience of a debugger built into that development tool but beyond the script validation feature of the Meridian Enterprise Script Editor, you cannot debug VBScript in the editor. For real debugging, you need a different tool. The tool to use depends on the client application where you want to debug the script:
-
PowerUser
provides a link to the Microsoft Script Debugger as described in Microsoft Script Debugger. Although the method described below can also be used with PowerUser, installing and using the Microsoft Script Debugger is just as effective and more convenient.
-
To debug VBScript running in a PowerWeb session, the debugging tool must be installed on the computer running Internet Information Services and you must have administrative rights on the computer. The Meridian vault configuration is cached by your browser during each PowerWeb session. You must log off of PowerWeb to close the current session and then log back on again to load any script changes that you make.
-
All other Windows applications where your VBScript code runs can be debugged using Visual Studio as described below.
The key to debugging VBScript from applications other than PowerUser is the ability of Visual Studio to attach itself to those applications.
Note:
Visual Studio 2008 or higher must be installed on the computer running the application from which you want to debug. Other debugging tools can be used as long as they support attaching themselves to a running process.
To debug VBScript in any Windows application with Visual Studio:
-
Start the application that hosts the VBScript that you want to debug.
-
Perform the actions that lead up to the point where your VBScript is about to execute and you want to start debugging.
-
Start Visual Studio.
The Visual Studio Start Page appears.
-
On the File menu, select New Project.
The New Project dialog appears.
-
In Project Types:
-
Expand Other Project Types.
-
Click Visual Studio Solutions.
-
Select Blank Solution.
-
Click OK.
A new project is created.
The name of the project is irrelevant because you will not add any code to the project and will discard it when you are finished using the debugger.
-
On the Tools menu, select Attach to Process.
The Attach to Process dialog appears.
-
Enable Show processes from all sessions.
The Available Processes list refreshes to show additional processes.
-
In Available Processes, select the name of the executable for the host application that you started in step 1 and click Attach.
For example, to debug a PowerWeb session:
-
Select w3wp.exe.
-
If the Attach Security Warning dialog box appears, click Attach.
The Solution Explorer opens and lists one or more occurrences of AMScriptHost.
-
On the Debug menu, select Break All (or press Ctrl+Alt+Break).
-
Perform the action in the host application that will run the VBScript code that you want to debug.
The Windows focus switches to Visual Studio and a new window opens, either VBScript - script block [dynamic] if a configuration expression is about to execute or BlueCielo VB Script [dynamic] if a sub-procedure or function in the event handler code module is about to execute. The next statement that will execute is highlighted and execution stops to allow you to debug.
When script first executes after the process is attached to Visual Studio, the vault's active VBScript configuration expressions and the event handler code module are loaded in Visual Studio. You might have to step over (press F10) some configuration expressions or sub-procedures before the particular expression, sub-procedure, or function that you want to debug is entered. Whenever the event handler code module is loaded, you can set breakpoints in the BlueCielo VB Script [dynamic] window and step through the code similar to debugging in PowerUser as described in Microsoft Script Debugger.
To open the BlueCielo VB Script [dynamic] window:
-
In the Solution Explorer, expand Script Documents.
-
Expand AMScriptHost.
-
Double-click BlueCielo VB Script.
Just like with using the Microsoft Script Debugger, to make changes to script code, you must edit it in Meridian Enterprise Configurator, save your changes, reopen the vault in the host application, and restart this task from step 5.
-
When you are finished debugging, exit Visual Studio without saving the project.
Following is a list of host applications related to Meridian Enterprise that you can attach to debug VBScript code:
-
Explorer.exe to debug the Application Integration
-
Acad.exe (or other application) to debug title block links
-
ConfiguratorU.exe to debug the Database Import Wizard
-
PowerUserU.exe to debug the Document Import tool
-
W3WP.exe to debug PowerWeb on the web server
To further aid in debugging, you can enable logging of VBScript events, command scripts, evaluated expressions, and external function calls. You can enable logging only for PowerUser and PowerWeb.
To enable VBScript logging and viewing:
- If PowerUser is open, close it.
-
In the Windows registry of the client PC, set the following registry values.
These are also described in the Accruent Meridian Enterprise Administrator's Guide:
- EnableScriptLog in HKEY_LOCAL_MACHINE\Software\Cyco\AutoManager Meridian\CurrentVersion\Client
- File, MaxSize, Format, Filter, and Mode in HKEY_CURRENT_USER\Software\Cyco\AutoManager Meridian\CurrentVersion\PowerUser\Settings\Log
The log file is restarted for each client session. The file includes the time, description, and source of the events.
Note:
-
Set the preceding settings in the Wow6432Node branch in the registry for 32-bit clients.
-
Logging is not available for Application Integration or the application links.
-
To add custom messages to the log, see Log method of the Client object.
To view the log with PowerUser:
-
On the View menu, point to Arrange Layout and then click Log.
The Log window can be floated or docked as described in the Accruent Meridian Enterprise User's Guide.
To download the log with the PowerWeb:
-
Enable the Download Log menu command by creating or changing the CanDownloadLog setting to 1 in the user's PowerWeb profile file.
This is described in “Deploying standard preferences” in the Accruent Meridian Enterprise Configuration Guide.
If the setting is 0 (default), the menu command is hidden.
-
Right-click to show the shortcut menu.
-
In the Miscellaneous group, click Download Log.
The file downloads to your browser where you can save and view it.