close
close
vbs set chrome as default browser

vbs set chrome as default browser

2 min read 29-09-2024
vbs set chrome as default browser

Setting Chrome as Your Default Browser with VBS: A Quick Guide

Tired of constantly switching your default browser? Want to make Chrome your go-to for browsing the web? VBScript offers a simple solution. Let's explore how to make Chrome your default browser using a VBS script.

Understanding the VBScript

VBScript, or Visual Basic Script, is a scripting language that allows you to automate tasks and manipulate various Windows settings. In this case, we'll use a VBS script to interact with the Windows registry, which stores information about your system settings, including your default browser.

The Code

Here's the VBS script to set Chrome as your default browser:

' Set Chrome as default browser
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\DefaultIcon", """" & WshShell.SpecialFolders("Local AppData") & "\Google\Chrome\Application\chrome.exe"",0"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\shell\open\command", """" & WshShell.SpecialFolders("Local AppData") & "\Google\Chrome\Application\chrome.exe"" %1"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", """" & WshShell.SpecialFolders("Local AppData") & "\Google\Chrome\Application\chrome.exe"",0"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice", """" & WshShell.SpecialFolders("Local AppData") & "\Google\Chrome\Application\chrome.exe"",0"

Set WshShell = Nothing

' Confirmation message
MsgBox "Chrome is now your default browser.", vbInformation

Explanation

  • Dim WshShell: This line declares a variable called WshShell, which will be used to interact with the Windows shell.
  • Set WshShell = CreateObject("WScript.Shell"): This line creates an instance of the WScript.Shell object and assigns it to the WshShell variable.
  • WshShell.RegWrite: This line is where the magic happens. It writes specific values to the Windows registry, associating Chrome with the necessary file types and protocols (HTTP, HTTPS).

How to Use the Script

  1. Save the code: Copy the code and paste it into a text editor like Notepad.
  2. Save as a VBS file: Save the file with a .vbs extension (for example, SetChromeDefault.vbs).
  3. Run the script: Double-click the saved .vbs file.

Important Considerations

  • User Permissions: This script requires administrator privileges. You might need to right-click the script file and select "Run as administrator."
  • Chrome Installation: Make sure Chrome is properly installed on your system.
  • Other Browsers: If you're using a different browser as your default, this script will overwrite its settings.

Additional Insights:

  • Alternative Methods: While using a VBS script is an effective way to set Chrome as your default, Windows also offers a built-in method. Go to "Settings" -> "Apps" -> "Default apps," and select Chrome for the relevant protocols (HTTP, HTTPS).
  • Customization: You can adapt this script to set other applications as your default browser by simply modifying the path and file names in the RegWrite lines.

Conclusion

Setting Chrome as your default browser with VBScript is a straightforward process. This guide provides a clear understanding of the script's code, how to use it, and important considerations to keep in mind. Remember, always back up your system before making significant changes to registry settings.

Related Posts


Latest Posts


Popular Posts