1. 'Registers Google Chrome Portable with Default Programs or Default Apps in Windows
  2. 'chromeportable.vbs - created on May 20, 2019 by Ramesh Srinivasan, Winhelponline.com https://is.gd/dtMxFW
  3. 'Last updated on 3-May-2020 - Added missing sub-keys and more associations. Properly enclosed file name parameter in double-quotes.
  4. Option Explicit
  5. Dim sAction, sAppPath, objFile, oFSO, sbaseKey, sbaseKey2
  6. Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
  7. Dim oFS0 : Set oFSO = CreateObject("Scripting.FileSystemObject")
  8. Set objFile = oFSO.GetFile(WScript.ScriptFullName)
  9. sAppPath = oFSO.GetParentFolderName(objFile)
  10. sAppPath = sAppPath & "\GoogleChromePortable.exe"
  11. If Not oFSO.FileExists (sAppPath) Then WScript.Quit
  12. 'If InStr(" ", sAppPath) <> 0 Then sAppPath = """" & sAppPath & """"
  13. ' Always wrap the directory path in quotes. Fixed on 3-May-2020 by applying one of the methods suggested here https://is.gd/BQR8w8
  14. sAppPath = chr(34) & sAppPath & Chr(34)
  15. ' Uncomment the following line to help with debugging the script - it shows sAppPath in a message box
  16. ' MsgBox "|" & sAppPath& "|"
  17. If WScript.Arguments.Count <> 0 Then
  18. If UCase(Trim(WScript.Arguments(0))) = "-REG" Then Call RegisterChromePortable(sAppPath)
  19. If UCase(Trim(WScript.Arguments(0))) = "-UNREG" Then Call UnregisterChromePortable(sAppPath)
  20. Else
  21. sAction = InputBox("Type REGISTER to add Chrome Portable to Default Apps. Type UNREGISTER to remove.", "Chrome Portable Registration", "REGISTER")
  22. If UCase(Trim(sAction)) = "REGISTER" Then Call RegisterChromePortable(sAppPath)
  23. If UCase(Trim(sAction)) = "UNREGISTER" Then Call UnregisterChromePortable(sAppPath)
  24. End If
  25. Sub RegisterChromePortable(sAppPath)
  26. sbaseKey = "HKCU\Software\"
  27. 'StartmenuInternet i.e. 'sbaseKey2' === 02 of kolbi.cz (https://is.gd/o5yyVp) ===
  28. sbaseKey2 = sbaseKey & "Clients\StartmenuInternet\Google Chrome Portable\"
  29. 'RegisteredApplications === 01 of kolbi.cz (https://is.gd/o5yyVp) ===
  30. WshShell.RegWrite sbaseKey & "RegisteredApplications\Google Chrome Portable", "Software\Clients\StartMenuInternet\Google Chrome Portable\Capabilities", "REG_SZ"
  31. 'Classes === 03 of kolbi.cz (https://is.gd/o5yyVp) ====
  32. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\", "Chrome HTML Document", "REG_SZ"
  33. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\AppUserModelId", "Chrome Portable", "REG_SZ"
  34. 'ChromeHTML\Application - 3-May-2020 - Added missing sub-key "Application"
  35. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\AppUserModelId", "Chrome Portable", "REG_SZ"
  36. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationIcon", sAppPath & ",0", "REG_SZ"
  37. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationName", "Google Chrome Portable Edition", "REG_SZ"
  38. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationDescription", "Access the internet", "REG_SZ"
  39. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\Application\ApplicationCompany", "Google LLC", "REG_SZ"
  40. 'DefaultIcon
  41. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\DefaultIcon\", sAppPath & ",0", "REG_SZ"
  42. '\shell\open\command
  43. WshShell.RegWrite sbaseKey & "Classes\ChromePRHTML\shell\open\command\", sAppPath & " -- " & """" & "%1" & """", "REG_SZ"
  44. 'StartmenuInternet === 02 of kolbi.cz (https://is.gd/o5yyVp) ===
  45. '@
  46. WshShell.RegWrite sbaseKey2, "Google Chrome Portable Edition", "REG_SZ"
  47. 'Capabilities
  48. WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationDescription", "Google Chrome Portable is a web browser that runs webpages and applications.", "REG_SZ"
  49. WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationIcon", sAppPath & ",0", "REG_SZ"
  50. WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationName", "Google Chrome Portable Edition", "REG_SZ"
  51. 'FileAssociations - Eight on 3-May-2020
  52. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.htm", "ChromePRHTML", "REG_SZ"
  53. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.html", "ChromePRHTML", "REG_SZ"
  54. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.pdf", "ChromePRHTML", "REG_SZ"
  55. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.shtml", "ChromePRHTML", "REG_SZ"
  56. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.svg", "ChromePRHTML", "REG_SZ"
  57. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.webp", "ChromePRHTML", "REG_SZ"
  58. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.xht", "ChromePRHTML", "REG_SZ"
  59. WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.xhtml", "ChromePRHTML", "REG_SZ"
  60. 'StartMenuInternet - 3-May-2020- Added missing sub-key "StartMenuInternet"
  61. WshShell.RegWrite sbaseKey2 & "Capabilities\Startmenu\StartMenuInternet", "Google Chrome Portable", "REG_SZ"
  62. 'URLAssociation - Thirteen on 3-May-2020
  63. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\ftp", "ChromePRHTML", "REG_SZ"
  64. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\http", "ChromePRHTML", "REG_SZ"
  65. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\https", "ChromePRHTML", "REG_SZ"
  66. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\irc", "ChromePRHTML", "REG_SZ"
  67. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\mailto", "ChromePRHTML", "REG_SZ"
  68. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\mms", "ChromePRHTML", "REG_SZ"
  69. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\news", "ChromePRHTML", "REG_SZ"
  70. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\nntp", "ChromePRHTML", "REG_SZ"
  71. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\sms", "ChromePRHTML", "REG_SZ"
  72. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\smsto", "ChromePRHTML", "REG_SZ"
  73. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\snews", "ChromePRHTML", "REG_SZ"
  74. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\tel", "ChromePRHTML", "REG_SZ"
  75. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\urn", "ChromePRHTML", "REG_SZ"
  76. WshShell.RegWrite sbaseKey2 & "Capabilities\URLAssociations\webcal", "ChromePRHTML", "REG_SZ"
  77. WshShell.RegWrite sbaseKey2 & "DefaultIcon\", sAppPath & ",0", "REG_SZ"
  78. '\shell\open\command
  79. WshShell.RegWrite sbaseKey2 & "shell\open\command\", sAppPath, "REG_SZ"
  80. 'Launch Default Apps after registering Chrome Portable
  81. 'WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"
  82. End Sub
  83. Sub UnregisterChromePortable(sAppPath)
  84. sbaseKey = "HKCU\Software\"
  85. sbaseKey2 = "HKCU\Software\Clients\StartmenuInternet\Google Chrome Portable"
  86. On Error Resume Next
  87. 'RegisteredApplications === 01 of kolbi.cz (https://is.gd/o5yyVp) ===
  88. WshShell.RegDelete sbaseKey & "RegisteredApplications\Google Chrome Portable"
  89. On Error GoTo 0
  90. 'Classes === 03 of kolbi.cz (https://is.gd/o5yyVp) ====
  91. WshShell.Run "reg.exe delete " & sbaseKey & "Classes\ChromePRHTML" & " /f", 0
  92. 'StartmenuInternet === 02 of kolbi.cz (https://is.gd/o5yyVp) ===
  93. 'Online research 3-May-2020, shows that getting VB script to removing REG keys is hit or miss.
  94. 'Run the VB Script with the (-REG) unregistration code along with reguler REG DELETE DOS code in a batch file.
  95. 'Below code doesn't work.
  96. 'WshShell.Run "reg.exe delete " & sbaseKey2 & " /f", 0
  97. 'Launch Default Apps after unregistering Chrome Portable
  98. 'WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"
  99. 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/