Solved

Set a registry key based on logic from the computer name

Posted on 2013-06-12
2
719 Views
Last Modified: 2013-06-14
I need to set a registry key value to be based upon the hostname of the Windows computer.

Our workstation names are generally as follows

AB983BVS01PC001
AB983BVS01PC002
AB983BVS01PC003
AB983BVS01PC004
AB983BVS02PC001
AB983BVS02PC002
AB983BVS02PC003
AB983BVS02PC004
etc.

I need to set a registry key value on each computer that is the first 12 Characters then adds 001 to it

e.g. on
AB983BVS02PC003 set the key to AB983BVS02PC001
AB983BVS55PC004 set the key to AB983BVS55PC001

The Registry key is

HKLM\Software\Application\
LeadComputer value AB983BVS02PC001

Can anyone suggest the best way to do this?

Thanks in advance!
0
Comment
Question by:aideb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 39243596
That's a one-liner in a batch script; you can roll that out as a startup (not logon!) script in a GPO applied to the machines in question:
reg add "HKLM\Software\Application" /v "LeadComputer" /t REG_SZ /d "%ComputerName:~0,12%001" /f

Open in new window

Assign computer startup scripts
http://technet.microsoft.com/en-us/library/cc779329(v=ws.10).aspx
0
 
LVL 2

Author Closing Comment

by:aideb
ID: 39247814
Excellent! Works a treat...
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

729 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