Windowsの「既定のブラウザ」にFirefox, Opera, DonutQ, IEなどをトグルで切り換えるVBSスクリプト
※2009/01/25追記 スクリプトを改良した「Windowsの「既定のブラウザ」にFirefox, Opera, DonutQ, IEなどをトグルで切り換えるVBSスクリプト(http, https, .htm, .html対応版)」という記事を投稿しました。
以前、「Windowsの「既定のブラウザ」をワンタッチで切り換えるVBSスクリプト」という記事を書いたのですが、それの焼き直しです。
以前はFirefoxとOperaの二つだけだったのでif文を使ったのですが、今回はDonutQ, IEなども使うためにcase文でトグルさせて既定のブラウザを切り換えます。
VBSスクリプトのショートカットをクリックする度に、既定のブラウザがFirefox→Opera→DonutQ→IE→Firefox という順番で切り換わる感じ。Safari, Chrome, Sleipnirなどを使っている場合は、スクリプトなどにご自由に加えて下さい。
尚、よくわからずに操作していますので、自己責任で(ぇ
VBSスクリプト
' ブラウザをトグルで切り換えるVBSスクリプト ' ※参考にさせて頂いたページ ' [観] IE が標準のブラウザ(通常使用するブラウザ)に戻らない ' http://watcher.moe-nifty.com/memo/2006/10/ie__2cb2.html ' [観] IE が標準のブラウザ(通常使用するブラウザ)に戻らない ― sleipnir から IE に戻す場合 ' http://watcher.moe-nifty.com/memo/2007/07/ie_sleipnir_ie_1528.html 'Windowsの「既定のブラウザ」をワンタッチで切り換えるVBSスクリプト - 雑木林とコンピュータのメモ帳 'http://d.hatena.ne.jp/dolphinkick/20080405/p1 Option Explicit Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") Dim strRegHttpKey, strRegHttpsKey, strRegHttpEntry, strRegHttpsEntry strRegHttpKey = "HKEY_CLASSES_ROOT\HTTP\" strRegHttpsKey = "HKEY_CLASSES_ROOT\HTTPS\" strRegHttpEntry = strRegHttpKey & "shell\" strRegHttpsEntry = strRegHttpKey & "shell\" Dim nowShell nowShell = objShell.RegRead(strRegHttpEntry) WScript.Echo "現在のHTTPのシェルは " & nowShell & " です。" Select Case nowShell Case "Firefox" objShell.RegWrite strRegHttpEntry, "DonutQ", "REG_SZ" objShell.RegWrite strRegHttpsEntry, "DonutQ", "REG_SZ" Case "DonutQ" objShell.RegWrite strRegHttpEntry, "Opera", "REG_SZ" objShell.RegWrite strRegHttpsEntry, "Opera", "REG_SZ" Case "Opera" objShell.RegWrite strRegHttpEntry, "IE", "REG_SZ" objShell.RegWrite strRegHttpsEntry, "IE", "REG_SZ" Case "IE" objShell.RegWrite strRegHttpEntry, "Firefox", "REG_SZ" objShell.RegWrite strRegHttpsEntry, "Firefox", "REG_SZ" Case Else objShell.RegWrite strRegHttpEntry, "Firefox", "REG_SZ" objShell.RegWrite strRegHttpsEntry, "Firefox", "REG_SZ" End Select nowShell = objShell.RegRead(strRegHttpEntry) WScript.Echo "HTTPのシェルを " & nowShell & " に変更しました。"
事前にレジストリに登録する内容
前提条件の各ブラウザのパスは、以下の通りです。ブラウザをインストールした環境に合わせて変更。
- Firefox D:\Program Files\Mozilla\Firefox.exe
- Opera D:\Program Files\Opera\Opera.exe
- DonutQ D:\Program Files\DonutQ\DonutQ.exe
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\HTTP\shell\DonutQ] @="DonutQ" [HKEY_CLASSES_ROOT\HTTP\shell\DonutQ\command] @="\"D:\\Program Files\\DonutQ\\DonutQ.exe\" %1" [HKEY_CLASSES_ROOT\HTTP\shell\Firefox] [HKEY_CLASSES_ROOT\HTTP\shell\Firefox\command] @="D:\\PROGRA~1\\MOZILL~1\\FIREFOX.EXE -requestPending -osint -url \"%1\"" [HKEY_CLASSES_ROOT\HTTP\shell\Opera] [HKEY_CLASSES_ROOT\HTTP\shell\Opera\command] @="\"D:\\Program Files\\Opera\\Opera.exe\" \"%1\"" [HKEY_CLASSES_ROOT\HTTP\shell\IE] [HKEY_CLASSES_ROOT\HTTP\shell\IE\command] @="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" \"%1\"" [HKEY_CLASSES_ROOT\HTTPS\shell\DonutQ] @="DonutQ" [HKEY_CLASSES_ROOT\HTTPS\shell\DonutQ\command] @="\"D:\\Program Files\\DonutQ\\DonutQ.exe\" \"%1\"" [HKEY_CLASSES_ROOT\HTTPS\shell\Firefox] [HKEY_CLASSES_ROOT\HTTPS\shell\Firefox\command] @="D:\\PROGRA~1\\MOZILL~1\\FIREFOX.EXE -requestPending -osint -url \"%1\"" [HKEY_CLASSES_ROOT\HTTPS\shell\Opera] [HKEY_CLASSES_ROOT\HTTPS\shell\Opera\command] @="\"D:\\Program Files\\Opera\\Opera.exe\" \"%1\"" [HKEY_CLASSES_ROOT\HTTPS\shell\IE] [HKEY_CLASSES_ROOT\HTTPS\shell\IE\command] @="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" \"%1\""
以上です。