Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch File to inject a Registry Changes

Posted on 2011-03-07
15
Medium Priority
?
1,092 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +2
15 Comments
 
LVL 22

Expert Comment

by:Jeremy Weisinger
ID: 35060558
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
ID: 35060594
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
ID: 35060647
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:Hath1ASC
ID: 35060694
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 22

Expert Comment

by:Jeremy Weisinger
ID: 35060745
@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
ID: 35061138
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
ID: 35061176
Hrm... sounds like you have some permission problems.  Are your users running as local administrators?
0
 

Author Comment

by:Cam3ron
ID: 35061235
Running as regular domain users
0
 
LVL 22

Accepted Solution

by:
Jeremy Weisinger earned 2000 total points
ID: 35061387
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
ID: 35062258
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
ID: 35062516
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 22

Expert Comment

by:Jeremy Weisinger
ID: 35062694
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
ID: 35063338
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 22

Expert Comment

by:Jeremy Weisinger
ID: 35063491
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
ID: 35063774
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

636 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