Solved

Set a registry key based on logic from the computer name

Posted on 2013-06-12
2
717 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 84

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
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.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

732 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