[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1102
  • Last Modified:

Batch File to inject a Registry Changes

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
Cam3ron
Asked:
Cam3ron
  • 6
  • 5
  • 2
  • +2
1 Solution
 
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
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
 
dkumar82Commented:
On command prompt type c:\> reg /?

you will get all keys, you can make easily batch file and push through group policy
0
 
lloydclintonCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Hath1ASCCommented:
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
 
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
@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
 
Cam3ronAuthor Commented:
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
 
lloydclintonCommented:
Hrm... sounds like you have some permission problems.  Are your users running as local administrators?
0
 
Cam3ronAuthor Commented:
Running as regular domain users
0
 
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
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
 
Cam3ronAuthor Commented:
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
 
Cam3ronAuthor Commented:
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
 
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
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
 
Cam3ronAuthor Commented:
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
 
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
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
 
Cam3ronAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 5
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now