Solved

Batch File to inject a Registry Changes

Posted on 2011-03-07
15
1,041 Views
Last Modified: 2012-05-11
I'm looking for a batch file to inject the below Registry Change out to all my staff computers in the domain.


The code below

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Main]
"Start Page"="http://OurHomePage.com"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDriveTypeAutoRun"=dword:00000091

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run]
"1"="C:\\Program Files\\Internet Explorer\\iexplore.exe"
0
Comment
Question by:Cam3ron
  • 6
  • 5
  • 2
  • +2
15 Comments
 
LVL 18

Expert Comment

by:Jeremy Weisinger
Comment Utility
If this is a domain then you can just use Group Policy to make this change.
http://support.microsoft.com/kb/274846

Otherwise you can stick a few "reg add" commands in a batch file. If you need help creating the batch let me know.
0
 
LVL 8

Expert Comment

by:dkumar82
Comment Utility
On command prompt type c:\> reg /?

you will get all keys, you can make easily batch file and push through group policy
0
 
LVL 3

Expert Comment

by:lloydclinton
Comment Utility
Group Policy would be the best way to do it, because if you are modifying certain parts of the registry your users may have to have a higher account level than user.  
0
 
LVL 1

Expert Comment

by:Hath1ASC
Comment Utility
Here's an article that explains two different methods you can choose between to apply registry settings via group policy:  http://blogs.technet.com/b/askds/archive/2007/08/14/deploying-custom-registry-changes-through-group-policy.aspx
0
 
LVL 18

Expert Comment

by:Jeremy Weisinger
Comment Utility
@lloydclinton, Note that the current user should have full access to the HKCU key. For HKLM you can run a startup script instead. No need to grant users more permissions than needed. ;-)
0
 

Author Comment

by:Cam3ron
Comment Utility
Thank you 35060558 - Does the below code look ok for my batch file?

I tried Group policy, but something on the current computer config group policy is not allowing my user config settings to apply.


Thank you 35060745 - how can i grant full access to the HKCU?


------------ my batch file -------------
REGEDIT5

@ECHO OFF
CLS
REG ADD [HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Main]
"Start Page"="http://OurHomePage.com"

REG ADD [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies]

REG ADD [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDriveTypeAutoRun"=dword:00000091

REG ADD [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run]
"1"="C:\\Program Files\\Internet Explorer\\iexplore.exe"

EXIT


0
 
LVL 3

Expert Comment

by:lloydclinton
Comment Utility
Hrm... sounds like you have some permission problems.  Are your users running as local administrators?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:Cam3ron
Comment Utility
Running as regular domain users
0
 
LVL 18

Accepted Solution

by:
Jeremy Weisinger earned 500 total points
Comment Utility
The issue is your REG ADD syntax is incorrect. User already have full control of the HKCU. It is their registry hive.

You can try this batch and see if it works for you:
 
::REGEDIT5

@ECHO OFF
CLS
REG ADD HKCU\Software\Policies\Microsoft\Internet Explorer\Main /v "Start Page" /t REG_SZ /d "http://OurHomePage.com" /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v "NoDriveTypeAutoRun" /t REG_DWORD /d 00000091 /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run /v "1" /t REG_SZ /d "C:\\Program Files\\Internet Explorer\\iexplore.exe" /f

EXIT

Open in new window


Note the data types and verify that I have them correct. For more information on the syntax type "REG ADD /?" at a command prompt.
0
 

Author Comment

by:Cam3ron
Comment Utility
Thank you! everything looks great, but the batch doesn't run on my pc. I'm just doubleclicking it from my desktop.

I checked the data types also - they look good.
0
 

Author Comment

by:Cam3ron
Comment Utility
i made a small change to your code, but no luck running it yet.

REG_SZ /d "C:\\Program Files\\Internet Explorer\\iexplore.exe" /f

--changed to--

REG_SZ /d "C:\\Program Files\Internet Explorer\iexplore.exe" /f
0
 
LVL 18

Expert Comment

by:Jeremy Weisinger
Comment Utility
You might want the double slashes in the path.
Try just putting the following in your batch and then post back any errors:
 
REG ADD HKCU\Software\Policies\Microsoft\Internet Explorer\Main /v "Start Page" /t REG_SZ /d "http://OurHomePage.com" /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v "NoDriveTypeAutoRun" /t REG_DWORD /d 00000091 /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run /v "1" /t REG_SZ /d "C:\\Program Files\\Internet Explorer\\iexplore.exe" /f

Pause

Open in new window

0
 

Author Comment

by:Cam3ron
Comment Utility
I checked the registry a few times and it appears that only the line #6 is working
this seems to work:
REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run /v "1" /t REG_SZ /d "C:\\Program Files\\Internet Explorer\\iexplore.exe" /f


Here's the error i'm getting with the pause command:

Error: Too many command-line parameters

Error: Invaled command-line parameters

The operation completed successfully
Press any key to continue ...
0
 
LVL 18

Expert Comment

by:Jeremy Weisinger
Comment Utility
Oops, saw that I was missing some quotes and I think that dword should be hex and not decimal.

Try this and let me know the results:

 
REG ADD "HKCU\Software\Policies\Microsoft\Internet Explorer\Main" /v "Start Page" /t REG_SZ /d "http://OurHomePage.com" /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v "NoDriveTypeAutoRun" /t REG_DWORD /d 0x91 /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run /v "1" /t REG_SZ /d "C:\\Program Files\\Internet Explorer\\iexplore.exe" /f

Pause

Open in new window

0
 

Author Comment

by:Cam3ron
Comment Utility
the whotle batch works now, all your code is correct. For whatever reason, when i copiyand paste the code, it throws an error, but when i typed it inthe bacth file line be line, i get no errors and it works. Thank you for all the help!!!I really appreciate it.

::REGEDIT5

@echo off
cls
REG ADD HKCU\Software\Policies\Microsoft\Internet Explorer\Main /v "Start Page" /t REG_SZ /d "http://stars/stars.net/dashboard/main.aspx?GLCode=021" /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v "NoDriveTypeAutoRun" /d 00000091 /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run /v "1" /t REG_SZ /d "C:\\Program Files\Internet Explorer\iexplore.exe" /f

exit
0

Featured Post

Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

728 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

9 Experts available now in Live!

Get 1:1 Help Now