We help IT Professionals succeed at work.

Deploy .reg script to the domain

What's the best way to deploy a reg file to the domain?  Can I just stick it into the \\domainname\sysvol ?  Would that work?
Comment
Watch Question

Commented:
I don't think placing it there will work out of the box, moreover it will probably be applied continuously.

I would suggest to write a batch file and insert it into a group policy's Scripts (Startup/Shutdown) or Scripts (Logon/Logoff) depending on your needs. This will provide the elevated privileges and you can have the batch file to do the following:

1. Detect if the registry key already exists (VBS or Batch depending on needs)

Ref: http://www.daniweb.com/software-development/legacy-languages/threads/61011/check-if-registry-key-exists-in-batch-file or http://blogs.technet.com/b/heyscriptingguy/archive/2004/10/29/how-can-i-tell-whether-a-value-exists-in-the-registry.aspx

2. Apply registry file with /s option if not exists

Ref: http://support.microsoft.com/kb/310516

Once the batch file is tested, add it into group policy and apply to the computers that need it. (http://support.microsoft.com/kb/198642)
Or you can use group policy preferences to deploy registry settings
http://technet.microsoft.com/en-us/library/cc771001.aspx

Author

Commented:
Hi guys, so to deploy via the Group Policy it only takes one key path.  My .reg has more than one.  
As for the bat file.  Renaming from .reg to .bat would that work?
Commented:
Nope, renaming from .reg to .bat/.cmd won't work. You will need to keep that .reg file and use the command regedt32.exe /s "filename.reg" in order to merge the registry file into reg. Therefore you will have 2 files, one is the batch and the other is the .reg.

Sample Batch without checking if key exists
====================================
@echo off
regedt32.exe /s "\\MyFileServer1\Registry\Registry.reg"

Author

Commented:
Got it.  So if I stick that bat file into the \\domainname\sysvol that would apply anytime anyone login to the servers?
Commented:
There is this video that will go thru GPO for scripts to run at logon.

2:15 onwards - http://www.youtube.com/watch?v=ap7uM0yiEkY

I would probably put the batch file on the file share and browse to it on the GPO.

There are other ways to do this too, which involves the Show Files button where you can copy and paste the batch and reg file so that it will replicate to other domain controllers. Using this, you just need to type the batch filename instead of browse.

Remember to test it out in a test environment.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.