Vbs Set Chrome As Default Browser

9 min read Oct 06, 2024
Vbs Set Chrome As Default Browser

Setting Chrome as your default browser in Windows is a straightforward process that can be achieved using a simple Visual Basic Script (VBS). This method offers a quick and efficient way to set Chrome as your primary browser, bypassing the conventional Windows settings interface.

Understanding the VBS Code

The core of the VBS code utilizes the Windows Registry to modify the default browser settings. The Registry acts as a central database storing system-wide configurations, including application associations. By modifying the appropriate registry keys, we can instruct Windows to use Chrome for web browsing tasks.

Here's a breakdown of the VBS code:

'Declare the registry key location for the default browser association
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

'Modify the registry key to set Chrome as the default browser
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.htm\OpenWithList", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\OpenWithList", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtml\OpenWithList", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtm\OpenWithList", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mht\OpenWithList", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mhtml\OpenWithList", "ChromeHTML", "REG_SZ"

'Declare the Chrome application path
Dim ChromePath
ChromePath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

'Set Chrome as the default handler for specific file extensions
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.htm\UserChoice", "%1", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.htm\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice", "%1", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtml\UserChoice", "%1", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtml\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtm\UserChoice", "%1", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtm\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mht\UserChoice", "%1", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mht\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mhtml\UserChoice", "%1", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mhtml\OpenWithProgids", "ChromeHTML", "REG_SZ"

'Set Chrome as the default handler for HTTP and HTTPS protocols
WshShell.RegWrite "HKCU\Software\Clients\StartMenuInternet\ChromeHTML", "", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Clients\StartMenuInternet\ChromeHTML\DefaultIcon", ChromePath, "REG_SZ"
WshShell.RegWrite "HKCU\Software\Clients\StartMenuInternet\ChromeHTML\URLAssociations", "http", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Clients\StartMenuInternet\ChromeHTML\URLAssociations", "https", "REG_SZ"

'Save the changes and exit the script
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.htm\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtml\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.shtm\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mht\OpenWithProgids", "ChromeHTML", "REG_SZ"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mhtml\OpenWithProgids", "ChromeHTML", "REG_SZ"

'Declare a message to indicate successful execution
MsgBox "Chrome has been set as the default browser!"

Explanation of the VBS code:

  • Registry Key Location: The script starts by defining the registry key location responsible for storing browser association settings.
  • Modifying Registry Keys: The code then modifies specific registry keys to associate Chrome with various file extensions (.htm, .html, .shtml, .shtm, .mht, .mhtml) and protocols (http, https).
  • Chrome Path: The script declares the default installation path for Chrome, which might need to be adjusted based on your installation location.
  • Default Handlers: It sets Chrome as the default handler for the specified file extensions and protocols, ensuring all web-related actions are handled by Chrome.
  • Saving Changes: The script saves the changes made to the registry and displays a message confirming successful execution.

Using the VBS Code

  1. Create a New VBS File: Create a new text file and rename it with a .vbs extension (e.g., SetDefaultChrome.vbs).
  2. Paste the Code: Copy and paste the provided VBS code into the newly created file.
  3. Modify the Chrome Path: If the default installation location of Chrome differs, update the ChromePath variable accordingly.
  4. Save the File: Save the VBS file.
  5. Run the Script: Double-click the saved VBS file to run the script.

Tips and Considerations

  • Admin Privileges: Ensure you are running the VBS script with administrator privileges. This is necessary to modify the system registry.
  • Chrome Installation Location: If Chrome is installed in a non-default location, adjust the ChromePath variable in the VBS script.
  • Alternative Methods: While this VBS method is effective, you can also set Chrome as the default browser using the Windows settings interface.
  • Backup: Before making significant changes to the registry, consider creating a system restore point or a registry backup to ensure you can revert any unintentional changes.

Conclusion

Using a simple VBS script provides a quick and efficient way to set Chrome as your default browser in Windows. By modifying the registry keys associated with file extensions and protocols, you can instruct Windows to utilize Chrome for web browsing activities. Remember to adjust the script based on your Chrome installation location and exercise caution when modifying registry settings.

Latest Posts