Solved

Batch Login Script - Update default homepage

Posted on 2016-11-17
8
13 Views
Last Modified: 2016-11-18
Is it possible via some login script to look and see what the user have setup as their home page?  If the default homepage is as followed then replace it with as followed?

Example default homepage is.
http://intranet/
replace with if it matches to
http://intranet2/
If no match then add http://intranet2/

There could be multiple default home pages, so only want to look if it matches the url before updating and if does not match then add.

Could this be done via batch script?
0
Comment
Question by:holemania
  • 6
  • 2
8 Comments
 

Author Comment

by:holemania
ID: 41892056
BTW I am looking at adding this under the "Secondary Start Pages" under the user's registry.
0
 
LVL 83

Expert Comment

by:oBdA
ID: 41892145
Try this; it's in test mode; remove the uppercase ECHO in line 29 to write the new value back to the registry.
@echo off
setlocal enabledelayedexpansion
set OldPage=http://intranet/
set NewPage=http://intranet2/

set Key=HKCU\Software\Microsoft\Internet Explorer\Main
set Value=Secondary Start Pages

reg.exe query "%Key%" /v "%Value%" >NUL 2>&1
if errorlevel 1 (echo No 'Secondary Start Pages', leaving ...&goto :eof)

for /f "tokens=5" %%a in ('reg.exe query "%Key%" /v "%Value%" /se ^, ^| find.exe /i "%Value%"') do set OldList=%%a
echo Old list: %Oldlist%
set NewList=
set ListUpdated=False
for %%a in (%OldList%) do (
	if /i "%%a"=="%OldPage%" (
		set NewList=!NewList!,%NewPage%
		set ListUpdated=True
	) else (
		set NewList=!NewList!,%%a
	)
)
if /i %ListUpdated%==False (
	set NewList=!NewList!,%NewPage%
)
set NewList=%NewList:~1%
echo New list: %NewList%
ECHO reg.exe add "%Key%" /v "%Value%" /t REG_MULTI_SZ /d %NewList% /s , /f

Open in new window

0
 

Author Comment

by:holemania
ID: 41892188
Thanks.  This is not writing to registry for some reason even after I removed the "ECHO" in line 29.
0
 

Author Comment

by:holemania
ID: 41892195
Going to step through the script and see if i find anything.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:holemania
ID: 41892200
Weird it didn't work at first, but seems to be working now.  So if there's no Secondary Start Pages, instead of going to end of file, can we create that key and continue?
0
 

Author Comment

by:holemania
ID: 41892202
The other issue is that it'll keep adding the new URL everytime I log in/out.  Is it possible to not added if it already exists?
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 41892261
@echo off
setlocal enabledelayedexpansion
set OldPage=http://intranet/
set NewPage=http://intranet2/

set Key=HKCU\Software\Microsoft\Internet Explorer\Main
set Value=Secondary Start Pages

for /f "tokens=5" %%a in ('reg.exe query "%Key%" /v "%Value%" /se ^, ^| find.exe /i "%Value%"') do set OldList=%%a
echo Old list: %Oldlist%
set NewList=
set ListUpdated=False
set FoundNewPage=False
for %%a in (%OldList%) do (
	if /i "%%a"=="%OldPage%" (
		set NewList=!NewList!,%NewPage%
		set ListUpdated=True
	) else (
		if /i "%%a"=="%NewPage%" (
			set FoundNewPage=True
		)
		set NewList=!NewList!,%%a
	)
)
if /i %FoundNewPage%==True (
	echo List is current.
	goto :eof
)
if /i %ListUpdated%==False (
	set NewList=!NewList!,%NewPage%
)
set NewList=%NewList:~1%
echo New list: %NewList%
ECHO reg.exe add "%Key%" /v "%Value%" /t REG_MULTI_SZ /d %NewList% /s , /f

Open in new window

0
 

Author Closing Comment

by:holemania
ID: 41893078
Thank you.  This works beautifully.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now