Solved

Batch File to inject a Registry Changes

Posted on 2011-03-07
15
1,054 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why pdf file doesn't open ? 7 65
DHCP lease duration / Migration 8 50
document a domain users/computers 1 34
Simulate file lock 5 31
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
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.

813 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