Site icon Winhelponline

Register Google Chrome Portable with Default Apps or Default Programs

A long time back, I made a simple program that will register Mozilla Firefox Portable with Default Programs or Default Apps in Windows. Many users asked if a tool can be made for other portable browsers, such as Opera, Chrome, etc.,

This post has a VBScript that will register or unregister Google Chrome Portable (from PortableApps.com) with Default Apps in a single click. After registering, you can set Chrome Portable as the default browser via Default Apps.

Register Chrome Portable with Default Apps or Default Programs

PortableApps.com is a popular portable software solution allowing you to take your favorite software with you. A fully open source and free platform, it works from any synced cloud folder (DropBox, Google Drive, Box, etc), from your local PC on an internal or external drive, or on any portable storage device (USB flash drive, memory card, portable hard drive, etc) moved between PCs.

To add Google Chrome Portable web browser to Default Apps, use the VBScript below.


'Registers Google Chrome Portable with Default Programs or Default Apps in Windows
'chromeportable.vbs - created on May 20, 2019 by Ramesh Srinivasan, Winhelponline.com
'v1.1 13-June-2019 - Enclosed file name parameter in double-quotes.
'v1.2 10-Sept-2020 - Fixed ApplicationIcon path. And added other supported URL protocols.
'v1.3 23-July-2022 - Minor bug fixes.

Option Explicit
Dim sAction, sAppPath, sExecPath, objFile, oFSO, sbaseKey, sbaseKey2, ArrKeys, regkey
Dim WshShell : Set WshShell = CreateObject("WScript.Shell") 
Dim oFS0 : Set oFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = oFSO.GetFile(WScript.ScriptFullName)
sAppPath = oFSO.GetParentFolderName(objFile)
sExecPath = sAppPath & "\GoogleChromePortable.exe"

'Quit if GoogleChromePortable.exe is missing in the current folder!
If Not oFSO.FileExists (sExecPath) Then
   MsgBox "Please run this script from Chrome Portable folder. The script will now quit.", _
   vbOKOnly + vbInformation, "Register Google Chrome Portable with Default Apps"
   WScript.Quit
End If

If InStr(sExecPath, " ") > 0 Then sExecPath = """" & sExecPath & """"
sbaseKey = "HKCU\Software\"

If WScript.Arguments.Count > 0 Then
   If UCase(Trim(WScript.Arguments(0))) = "-REG" Then Call RegisterChromePortable
   If UCase(Trim(WScript.Arguments(0))) = "-UNREG" Then Call UnregisterChromePortable
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
   If UCase(Trim(sAction)) = "UNREGISTER" Then Call UnregisterChromePortable
End If


Sub RegisterChromePortable
   sbaseKey2 = sbaseKey & "Clients\StartmenuInternet\Google Chrome Portable\"
   
   WshShell.RegWrite sbaseKey & "RegisteredApplications\Google Chrome Portable", _
   "Software\Clients\StartMenuInternet\Google Chrome Portable\Capabilities", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\", "Chrome HTML Document", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\AppUserModelId", "Chrome Portable", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\Application\AppUserModelId", "Chrome Portable", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\Application\ApplicationIcon", sExecPath & ",0", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\Application\ApplicationName", "Google Chrome Portable", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\Application\ApplicationDescription", "Access the internet", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\Application\ApplicationCompany", "Google Inc.", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\DefaultIcon\", sExecPath & ",0", "REG_SZ"
   WshShell.RegWrite sbaseKey & "Classes\ChromeHTML2\shell\open\command\", sExecPath & " -- " & """" & "%1" & """", "REG_SZ"
   
   WshShell.RegWrite sbaseKey2, "Google Chrome Portable Edition", "REG_SZ"
   WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationDescription", "Google Chrome Portable Edition", "REG_SZ"
   WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationIcon", sExecPath & ",0", "REG_SZ"
   WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationName", "Google Chrome Portable Edition", "REG_SZ"   
   
   
   ArrKeys = Array ("FileAssociations\.htm", _
   "FileAssociations\.html", _
   "FileAssociations\.shtml", _
   "FileAssociations\.xht", _
   "FileAssociations\.xhtml", _
   "FileAssociations\.webp", _
   "URLAssociations\ftp", _
   "URLAssociations\http", _
   "URLAssociations\https", _
   "URLAssociations\irc", _
   "URLAssociations\mailto", _
   "URLAssociations\mms", _
   "URLAssociations\news", _
   "URLAssociations\nntp", _
   "URLAssociations\sms", _
   "URLAssociations\smsto", _
   "URLAssociations\tel", _
   "URLAssociations\url", _
   "URLAssociations\webcal")
   
   For Each regkey In ArrKeys
      WshShell.RegWrite sbaseKey2 & "Capabilities\" & regkey, "ChromeHTML2", "REG_SZ"
   Next
   
   WshShell.RegWrite sbaseKey2 & "DefaultIcon\", sExecPath & ",0", "REG_SZ"
   WshShell.RegWrite sbaseKey2 & "shell\open\command\", sExecPath, "REG_SZ"
   
   'Launch Default Apps after registering Chrome Portable   
   WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"  
End Sub


Sub UnregisterChromePortable
   
   sbaseKey2 = "HKCU\Software\Clients\StartmenuInternet\Google Chrome Portable"
   
   On Error Resume Next
   WshShell.RegDelete sbaseKey & "RegisteredApplications\Google Chrome Portable"
   On Error GoTo 0
   
   WshShell.Run "reg.exe delete " & sbaseKey & "Classes\ChromeHTML2" & " /f", 0
   WshShell.Run "reg.exe delete " & chr(34) & sbaseKey2 & chr(34) & " /f", 0
   
   'Launch Default Apps after unregistering Chrome Portable   
   WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"   
End Sub

Usage

  1. Copy the above VBScript code to Notepad and save the file as chromeportable.vbs
  2. Move the file to your removable or USB drive. The script file should be placed in the GoogleChromePortable folder for it to work.
  3. Double-click chromeportable.vbs to run it.
  4. Type REGISTER and click OK to add Chrome Portable to Default Apps.
  5. The script launches Default Apps or Default Programs automatically. Select Google Chrome Portable from the list and set it as the default.

To remove Google Chrome Portable from Default Apps, rerun the script and this time, type UNREGISTER and click OK.

RELATED: Change Default Apps, Browser or File Association via Command-line in Windows 10

Select the default browser

Note that the script registers the browser with Default Apps, but doesn’t set it as the default. This is something the user has to do manually, especially in Windows 10.

So, the script launches the Default Programs or the Default Apps (in Windows 10) window after you register or unregister the portable browser. To prevent the script from launching the Default Apps window every time, delete the following line (2 occurrences) in the script and save it:

WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"

You may also use the SetuserFTA utility to set the default browser via command-line or shortcut, if you don’t want to go through Default Apps. See Change Default Apps, Browser or File Association via Command-line.

Run the script non-interactively

To register or unregister Chrome Portable silently (non-interactively), you can use the following syntax:

wscript.exe D:\GoogleChromePortable\chromeportable.vbs -REG

wscript.exe D:\GoogleChromePortable\chromeportable.vbs -UNREG

And you can even create shortcuts for the above commands:

Hope you found the script a tad useful! If you’re looking for a similar script for other portable apps, pls let’s know in the Comments section below.

Exit mobile version