Dim Browser, ObjArgs, StrPath, WshShell
Browser = "C:\Program Files\Mozilla\mozilla.exe"
Set ObjArgs = WScript.Arguments
StrPath = ObjArgs(0)
StrPath = Replace(StrPath, "\", "/")
StrPath = Replace(StrPath, " ", "%20")
StrPath = "file:///" + StrPath
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run Chr(34) & Browser & Chr(34) & " -url " & StrPath
Set ObjArgs = Nothing
Set WshShell = Nothing
WScript.Quit
なんとなく書いてみる。
いや、MozillaにはURLを一部エスケープする必要があるので、作ったんですが、JScript使えば一発じゃんということを数時間後に思ったりする。が、そうでもないことに気づく。
var Browser, ObjArgs, StrPath, WshShell;
Browser = "C:\\Program Files\\Mozilla\\mozilla.exe";
ObjArgs = WScript.Arguments;
StrPath = ObjArgs(0);
StrPath = StrPath.replace(/\\/g, "\/");
StrPath = encodeURI(StrPath);
StrPath = "file:///" + StrPath;
WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("\"" + Browser + "\" -url " + StrPath);
WScript.Quit();
まーJScriptの方が確実だな。VBScriptの方は空白しかエスケープしてないし(よくよく考えるとインチキだ)。