I've been looking for how to do this but failed.
I want a batch file to change the homepage for all my browsers (IE, Firefox and Chrome) at the same time may be?
I need code to make this file..
I have done Like this.. but in vain.
@echo off
REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "http://www.google.com/" /F
@echo off
REG ADD "HKCU\SOFTWARE\MICROSOFT\GOOGLE CHROME\MAIN" /V "START PAGE" /D "http://www.google.com/" /F
@echo off
REG ADD "HKCU\SOFTWARE\MICROSOFT\MOZILLA FIREFOX\MAIN" /V "START PAGE" /D "http://www.google.com/" /F
In Internet Explorer:
you can do that like below:
REG ADD "HKCU\Software\Microsoft\Internet Explorer\Main" /V "Start Page" /D "http://www.google.com/" /F
In Firefox:
FF uses a JavaScript (prefs.js in your FireFox User Profile) and not a Registry entry.
What you will need to do is programmatically edit the prefs.js file in the user profile for Firefox found in the directory C:\Users\ [USERNAME]\AppData\Roaming\Mozilla\Firefox\Profiles\ [Subfolder]
You will need to add or edit the line that looks like: user_pref("browser.startup.homepage", "www.google.com"); as mentioned:
@Echo off
taskkill /im firefox.exe* /f
cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
cd *.default
set ffile=%cd%
echo user_pref("browser.startup.homepage", "https://www.google.com");>>"%ffile%\prefs.js"
set ffile=
cd %windir%
Another option using JavaScript is:
You can change the Firefox homepage by setting the preference "browser.startup.homepage"
The easiest way to do this in an add-on via JavaScript is:
Components.utils.import("resource://gre/modules/Services.jsm");
Services.prefs.setCharPref("browser.startup.homepage", "http://www.google.com");
In Google chrome:
chrome settings are in %USERPROFILE%\Local Settings\Application Data\Google\Chrome\User Data.ChromotingConfig.json and are a little bit encrypted as npocmaka mentioned.
but you can do a workaround like by just pasting following javascript into the "Home Page" pref field (under your Chrome options) and it works as expected when clicking the "Home" button.
javascript:(function(){ window.location.href='http://www.google.com/';})();
I haven't looked into changing IE or Chrome, but here's what I found for Firefox:
Firefox doesn't store its settings in the registry, but rather it saves it in a prefs.js
file within your Application Data folder. (In Win7, the folder is C:\Users\YOURUSERNAME\AppData\Roaming\Mozilla\Firefox\Profiles\YOURPROFILE\
)
To change the information within your about:config
preferences (in this case the homepage) you need to modify the prefs.js
file.
The batch command I found to change text within this file is
cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
cd *.default
set ffile=%cd%
echo user_pref("browser.startup.homepage", "https://www.google.com/search?q=test");>>"%ffile%\prefs.js"
set ffile=
cd %windir%
Remember that when modifying prefs.js through command prompt, it's essential that Firefox is off when you modify the settings you need to change. If Firefox is still on when you try to change this file, your update will fail after you load Firefox back up. In deploying my batch file across the network I included a command to close Firefox and wait for a moment to give Firefox a chance to clear out of memory. (I got it to wait by pinging 1.1.1.1 for three seconds) Once the update executed, I told command prompt to reload Firefox so that I could check to verify that my homepage was successfully updated.
Here's my end code:
@Echo off
taskkill /im firefox.exe* /f
ping 1.1.1.1 -n 1 -w 3000 > nul
cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
cd *.default
set ffile=%cd%
echo user_pref("browser.startup.homepage", "https://www.google.com/search?q=test");>>"%ffile%\prefs.js"
set ffile=
cd %windir%
start firefox.exe
I've verified that this code works on Windows XP and Windows 7.
The reg command
reg /?
Here's an example reading a registry key
Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With