WSHを使ってMozillaでHTMLファイルを開く
Posted at 2003-01-09T00:00:00+09:00 in Coding
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の方は空白しかエスケープしてないし(よくよく考えるとインチキだ)。
Weblog archives
by Month
- October, 2006 (9)
- September, 2006 (23)
- August, 2006 (31)
- July, 2006 (8)
- October, 2005 (13)
- September, 2005 (24)
- August, 2005 (26)
- July, 2005 (2)
- June, 2005 (2)
- May, 2005 (13)
- April, 2005 (30)
- March, 2005 (33)
- February, 2005 (13)
- January, 2005 (10)
- December, 2004 (28)
- November, 2004 (27)
- October, 2004 (25)
- September, 2004 (38)
- August, 2004 (52)
- July, 2004 (45)
- June, 2004 (41)
- May, 2004 (48)
- April, 2004 (36)
- March, 2004 (51)
- February, 2004 (55)
- January, 2004 (63)
- December, 2003 (46)
- November, 2003 (63)
- October, 2003 (92)
- September, 2003 (61)
- August, 2003 (93)
- July, 2003 (57)
- May, 2003 (5)
- April, 2003 (35)
- March, 2003 (35)
- February, 2003 (37)
- January, 2003 (62)
- December, 2002 (32)
This page was last modified on 2003-11-18T19:31:44+09:00 (in 0.125 secs).