- 'Registers Google Chrome Portable with Default Programs or Default Apps in Windows
- 'chromeportable.vbs - created on May 20, 2019 by Ramesh Srinivasan, Winhelponline.com https://is.gd/dtMxFW
- 'Last updated on 3-May-2020 - Added missing sub-keys and more associations. Properly enclosed file name parameter in double-quotes.
- Option Explicit
- Dim sAction, sAppPath, objFile, oFSO, sbaseKey, sbaseKey2
- Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
- Dim oFS0 : Set oFSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = oFSO.GetFile(WScript.ScriptFullName)
- sAppPath = oFSO.GetParentFolderName(objFile)
- sAppPath = sAppPath & "\GoogleChromePortable.exe"
- If Not oFSO.FileExists (sAppPath) Then WScript.Quit
- 'If InStr(" ", sAppPath) <> 0 Then sAppPath = """" & sAppPath & """"
- ' Always wrap the directory path in quotes. Fixed on 3-May-2020 by applying one of the methods suggested here https://is.gd/BQR8w8
- sAppPath = chr(34) & sAppPath & Chr(34)
- ' Uncomment the following line to help with debugging the script - it shows sAppPath in a message box
- ' MsgBox "|" & sAppPath& "|"
- If WScript.Arguments.Count <> 0 Then
- If UCase(Trim(WScript.Arguments(0))) = "-REG" Then Call RegisterChromePortable(sAppPath)
- If UCase(Trim(WScript.Arguments(0))) = "-UNREG" Then Call UnregisterChromePortable(sAppPath)
- Else
- sAction = InputBox("Type REGISTER to add Chrome Portable to Default Apps. Type UNREGISTER to remove.", "Chrome Portable Registration", "REGISTER")
- If UCase(Trim(sAction)) = "REGISTER" Then Call RegisterChromePortable(sAppPath)
- If UCase(Trim(sAction)) = "UNREGISTER" Then Call UnregisterChromePortable(sAppPath)
- End If
- Sub RegisterChromePortable(sAppPath)
- sbaseKey = "HKCU\Software\"
- 'StartmenuInternet i.e. 'sbaseKey2' === 02 of kolbi.cz (https://is.gd/o5yyVp) ===
- sbaseKey2 = sbaseKey & "Clients\StartmenuInternet\Google Chrome Portable\"
- 'RegisteredApplications === 01 of kolbi.cz (https://is.gd/o5yyVp) ===
- WshShell.RegWrite sbaseKey & "RegisteredApplications\Google Chrome Portable", "Software\Clients\StartMenuInternet\Google Chrome Portable\Capabilities", "REG_SZ"
- 'Classes === 03 of kolbi.cz (https://is.gd/o5yyVp) ====
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\", "Chrome HTML Document", "REG_SZ"
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\AppUserModelId", "Chrome Portable", "REG_SZ"
- 'ChromeHTML\Application - 3-May-2020 - Added missing sub-key "Application"
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\AppUserModelId", "Chrome Portable", "REG_SZ"
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationIcon", sAppPath & ",0", "REG_SZ"
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationName", "Google Chrome Portable Edition", "REG_SZ"
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationDescription", "Access the internet", "REG_SZ"
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationCompany", "Google LLC", "REG_SZ"
- 'DefaultIcon
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\DefaultIcon\", sAppPath & ",0", "REG_SZ"
- '\shell\open\command
- WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\shell\open\command\", sAppPath & " -- " & """" & "%1" & """", "REG_SZ"
- 'StartmenuInternet === 02 of kolbi.cz (https://is.gd/o5yyVp) ===
- '@
- WshShell.RegWrite sbaseKey2, "Google Chrome Portable Edition", "REG_SZ"
- 'Capabilities
- WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationDescription", "Google Chrome Portable is a web browser that runs webpages and applications.", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationIcon", sAppPath & ",0", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationName", "Google Chrome Portable Edition", "REG_SZ"
- 'FileAssociations - Eight on 3-May-2020
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.htm", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.html", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.pdf", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.shtml", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.svg", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.webp", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.xht", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.xhtml", "ChromePRHTML", "REG_SZ"
- 'StartMenuInternet - 3-May-2020- Added missing sub-key "StartMenuInternet"
- WshShell.RegWrite sbaseKey2 & "Capabilities\Startmenu\StartMenuInternet", "Google Chrome Portable", "REG_SZ"
- 'URLAssociation - Thirteen on 3-May-2020
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\ftp", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\http", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\https", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\irc", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\mailto", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\mms", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\news", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\nntp", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\sms", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\smsto", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\snews", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\tel", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\urn", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\webcal", "ChromePRHTML", "REG_SZ"
- WshShell.RegWrite sbaseKey2 & "DefaultIcon\", sAppPath & ",0", "REG_SZ"
- '\shell\open\command
- WshShell.RegWrite sbaseKey2 & "shell\open\command\", sAppPath, "REG_SZ"
- 'Launch Default Apps after registering Chrome Portable
- 'WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"
- End Sub
- Sub UnregisterChromePortable(sAppPath)
- sbaseKey = "HKCU\Software\"
- sbaseKey2 = "HKCU\Software\Clients\StartmenuInternet\Google Chrome Portable"
- On Error Resume Next
- 'RegisteredApplications === 01 of kolbi.cz (https://is.gd/o5yyVp) ===
- WshShell.RegDelete sbaseKey & "RegisteredApplications\Google Chrome Portable"
- On Error GoTo 0
- 'Classes === 03 of kolbi.cz (https://is.gd/o5yyVp) ====
- WshShell.Run "reg.exe delete " & sbaseKey & "Classes\ChromePRHTML" & " /f", 0
- 'StartmenuInternet === 02 of kolbi.cz (https://is.gd/o5yyVp) ===
- 'Online research 3-May-2020, shows that getting VB script to removing REG keys is hit or miss.
- 'Run the VB Script with the (-REG) unregistration code along with reguler REG DELETE DOS code in a batch file.
- 'Below code doesn't work.
- 'WshShell.Run "reg.exe delete " & sbaseKey2 & " /f", 0
- 'Launch Default Apps after unregistering Chrome Portable
- 'WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"
- End Sub
Register Google Chrome Portable with Default Apps or Default Programs
For more information see https://www.winhelponline.com/blog/register-google-chrome-portable-with-default-apps-or-default-programs/