Solved

Batch File to inject a Registry Changes

Posted on 2011-03-07
15
1,062 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
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 18

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 18

Accepted Solution

by:
Jeremy Weisinger earned 500 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 18

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 18

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
best counters for cpu high usage 3 43
PerfMon Report Time Out 6 42
Audit active directory trust relationships 2 27
Auto-launch VPN via Wifi 7 49
This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

790 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