Solved how to lock IE homepage via batch-file?

October 12, 2012 at 07:54:15
Specs: Windows 7
Hey guys im new here and I've the problem that I'm working in a internet coffee as an auxiliary and the dumb thing is that people are always changing the homepage of IE and I have to reset them manually each time (pretty time consuming). So I want to write a batch file, that locks the homepage of IE, but i don't know how to code such a complicated batch file :(. So If anybody of you could help me I would be very pleased.

Here is a manual step by step guide: http://www.techiecorner.com/8/how-t...

PS: Sorry for my bad englisch, but its not my mother tongue


See More: how to lock IE homepage via batch-file?

Report •


✔ Best Answer
October 13, 2012 at 02:32:57
Here, changed the method to modify registry and added homepage checking.
@echo off & setlocal enabledelayedexpansion
set reset=%tmp%\rhp.reg
set lock=%tmp%\lock.reg
set homepage=mypage
reg query "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Start Page" | find "%homepage%" > nul 2>&1
if not errorlevel 1 Goto :LOCK
> "%reset%" (
echo.Windows Registry Editor Version 5.00
echo.[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
echo."Start Page"="%homepage%"
)
regedit /s %reset%
del %reset%
:LOCK
> %lock% (
echo.Windows Registry Editor Version 5.00
echo.[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Control Panel]
echo."HomePage"=dword:00000001
echo.[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
echo."HomePage"=dword:00000001
)
regedit /s %lock%
del %lock%
exit


#1
October 12, 2012 at 08:41:26
lol complicated?
Replace all the shortcuts referring to ie to this script and obviously change the icon+name to ie.
Also, "compile" this to silent by using freely available "compilers".
::::BEGIN DEM SCRIPTS
@echo off & setlocal enabledelayedexpansion
start "" /W "C:\Program Files\Internet Explorer\iexplore.exe"
set homepage=mywebsite
set reset=%tmp%\rhp.reg
reg query "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Start Page" | find "%homepage%" > nul 2>&1
if not errorlevel 1 exit
> "%reset%" (
echo.Windows Registry Editor Version 5.00
echo.[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
echo."Start Page"="%homepage%"
)
regedit /s %reset%
del %reset%
exit

:::::::::::::::::;;END:::::::::::::::::::::
Modify to your preference.

Report •

#2
October 12, 2012 at 08:44:47
Also for god sake, use deep freeze or shadow defender. You could protect the registry key HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main to prevent any attempt at modification which would be a better solution.

Report •

#3
October 12, 2012 at 11:11:07
first of all, thanks thebest123456 for the quick response, i'll try your code later tonight :)

Report •

Related Solutions

#4
October 12, 2012 at 12:12:24
Just solved the possible problems running multiple instances might cause:
::BEGIN
@echo off & setlocal enabledelayedexpansion
set homepage=mywebsite
start "" /W "C:\Program Files\Internet Explorer\iexplore.exe"
set reset=%tmp%\rhp.reg
reg query "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Start Page" | find "%homepage%" > nul 2>&1
if not errorlevel 1 exit
if not exist %reset% (
> "%reset%" (
echo.Windows Registry Editor Version 5.00
echo.[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
echo."Start Page"="%homepage%"
)
)
regedit /s %reset%
del %reset%
exit

::END
An alternative would be to be checking if iexplorer.exe is running after every x secs, if it is not, then reset back home page and go through a loop. Obviously not as simple as that but it's an outline.

Report •

#5
October 12, 2012 at 15:00:38
maybe this is a really stupid question, but do i have to replace "mypage" with the page i would like to set as homepage?

edit:
I've created a batch file with your code and everything seemd to work great, but after i've run the batch file everybody can simply change the start page to what ever he or she wants to... So im sorry to say, but actually your batch file doesn't protect the homepage of being changed :/

Hopefully you are able to write a code that prevents the homepage of being changed.

Please check out the link ive posted in my first post, maybe it makes things clearer.

http://www.techiecorner.com/8/how-t...


Report •

#6
October 12, 2012 at 22:22:53
@julesbojo, which is why i said to have that run in replacement of IE, meaning every time the user wants to open IE, that batch file is run in the background and internet explorer, once explorer is dead, it will check for any homepage modifications and then exit. If they want to use IE again they just run the file so there's no problem. Anyway will take a look at what you provided.

Report •

#7
October 12, 2012 at 22:55:12
maybe this, based on the excellent tech site advice:
::===== begin
@echo off & setlocal
set r=\SOFTWARE\Policies\Microsoft\Windows\internet explorer\control panel" /v HomePage /t REG_DWORD /d 0x1 /f
reg add "HKCU%r%
reg add "HKLM%r%
::===== end script

this script would need to be executed on each computer, but only once. (There may be a way to broadcast it, but I'm not ready to deal with that hurdle at this point.) It adds the material to the registry of the local computer that will "allegedly" "lock" the homepage. I have tried the registry injection with success, but not tried the ultimate effect on IE.


Report •

#8
October 13, 2012 at 02:32:57
✔ Best Answer
Here, changed the method to modify registry and added homepage checking.
@echo off & setlocal enabledelayedexpansion
set reset=%tmp%\rhp.reg
set lock=%tmp%\lock.reg
set homepage=mypage
reg query "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Start Page" | find "%homepage%" > nul 2>&1
if not errorlevel 1 Goto :LOCK
> "%reset%" (
echo.Windows Registry Editor Version 5.00
echo.[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
echo."Start Page"="%homepage%"
)
regedit /s %reset%
del %reset%
:LOCK
> %lock% (
echo.Windows Registry Editor Version 5.00
echo.[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Control Panel]
echo."HomePage"=dword:00000001
echo.[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
echo."HomePage"=dword:00000001
)
regedit /s %lock%
del %lock%
exit

Report •

#9
October 13, 2012 at 02:33:08
@ thebest123456 oh i see. Yes if the ie shortcut is replaced by this batch file than it works quite well, but nevertheless i would prefer nbranes solution, the only problem is that if you run nbranes code in cmd as administrator it says that everything worked fine, but if check the registry you won't see any changes, so still everybody could change the homepage easily.

Report •

#10
October 13, 2012 at 02:38:40
FINALLY it works! Big thanks to both of you :)

Report •

#11
October 13, 2012 at 02:48:52
Btw, the problem was i had to replace the method used to modify the registry, for some reason the reg add command doesn't work most of the time.

Report •

Ask Question