Script to import Reg Key based on user name

I am looking for a script that can look at a list of user names and phone extensions, then if there is a match import a regkey into HKCU.  Is this possible?

It would look like this.
If username is jsmith then import key

Any help would be appreciated.


Who is Participating?
You could either place them in Netlogon and call the .cmd file from the "Logon script" line in AD Users and Computers or create a Group Policy Object with an entry under the node User Configuration\Windows Settings\Scripts\Logon.

The way the script is written, phonelist.txt must be located in the same directory as the .cmd file.
Please provide an example of the list and the registry entries you would want to import.  Are you wanting it to compare entries on the list with the name of the user who is currently logged in?
goodadminAuthor Commented:
I don't have a list yet.  I need to import a RegKey that contains the user phone extension.  So the extension number is the value that I need to import, in this case each user would have a different value for the extension.  See below, my extension is "3366"


Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Ok, well assuming you have a comma-delimited list named phonelist.txt where the lines look like this:

Then you could use the script below.  Note that the REG command isn't included with Windows 2000, so if it needs to run on 2000 clients then you'll need to place a copy of REG.EXE in the same location as the script.

Paste the text below the line into a new file with a .cmd extension.

@echo off

set phonekey=HKCU\Software\Octel\Geneva\VoiceControl\VMCs\{F3F6095A-AF8C-11D1-84B8-00C04FA310F7}

for /F "tokens=1,2 delims=," %%G in (phonelist.txt) do (
 if "%%G"=="%username%" reg add "%phonekey%" /v PhoneNumber /t REG_SZ /d "%%H" /f

goodadminAuthor Commented:
This is exactly what I was looking for.  I've tested this and it works like a charm. One question, do I place the statement and text file in the Netlogon directory in order for this to work when the users login?

goodadminAuthor Commented:
Thank You
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.