Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 668
  • Last Modified:

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.


  • 3
  • 3
1 Solution
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"


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

Independent Software Vendors: 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!

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?

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.
goodadminAuthor Commented:
Thank You

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now