Launching the default browser – an answer :)

OK, I promised the answer I’m using: run wscript on the following:

function main()  {
  var i;

  // Create an instance of the scripting Shell Object
  WshShell = WScript.CreateObject("WScript.Shell");

  if(WScript.Arguments.length >= 1) {
    // Have the Shell Object call ShellExecute on the 1st argument.
    WshShell.Run(WScript.Arguments(0), 1, 0);

  // Destroy the Shell Object


Simple, no? Coming up with this led me through the confusing labyrinth of Wscript/Cscript, JScript, VBA and a few other things that I cna’t remember anymore. It’s been an intense couple of days! What I learned, though, has, as usual, been invaluable. I finally “got” the WScript object model and how it differs from the language that’s being used to implement.

For completeness (and so that I have a record of some of these incredible sites and pages), here’s where I went:

ShellExecute is in shell32.dll. Method of operation (how it decides to start a new instance, what registry keys it looks in, etc.) is in MSKB 224816.

MSKB 164787) describes the RunDLL and RunDLL32 interface and mechanism.

Then there’s this article in the Microsoft Systems Journal which describes how to script an autorun utility.

WhirlyWiryWeb has a utility called ShellExe.exe which will launch documents through ShellExecute. The download is only 14K. The article and the download is available at It takes multiple arguments and goes through trying to open each one of them till it succeeds. Kinda overkill for me and what I’m trying to do but it’s still a good starting point.

“Fundamental Shell Concepts” at explains some of the shell space naming, including how to locate the “name” of special folders. For instance, “My Computer” is “::{20D04FE0-3AEA-1069-A2D8-08002B30309D}” (sans quotes). You can use this as an address (like C:\WINDOWS) in Explorer, for instance.

Another good place I found some JScripting help was at newObjects in their Code snippets section. This particular article has 2 snippets: a sprintf implementation in JScript and a file preprocessor. I took some JScript hints from them.

The Google search terms I used to find most of this stuff was simply “jscript parameters” without the quotes. I found a VERY good document on JScript at There are LOTS and LOTS of documents there.

Leave a Comment