Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Re: Update registry with part of Computers Name

Reply
 
Old 07-26-2009   #1 (permalink)
Richard Mueller [MVP]


 
 

Re: Update registry with part of Computers Name


"Danc383@xxxxxx" <Danc383hotmailcom@xxxxxx> wrote in
message news8780D55-D6DE-44E8-8572-45F58420B68D@xxxxxx
Quote:

> Hi,
>
> Please can someone help?
>
> I have no idea where to start with this..
>
> I need a script that when run will find the computers name e.g.
> "TSNET-WKS06"
> Then updates the registry with the last 2 digits of the computer name
>
> Key to be updated:
> [HKEY_LOCAL_MACHINE\SOFTWARE\LOCDES\SYSIFO\Terminal]
> "TerminalId"="1"
>
> New Value
> "TerminalId"="06"
>
Assuming the script is run on the computer, one solution could be:
========
Option Explicit
Dim objNetwork, strComputer, objShell

' Retrieve NetBIOS name of computer.
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

' Assign value in local registry.
Set objShell = CreateObject("Wscript.Shell")
objShell.RegWrite "HKLM\Software\LOCDES\SYSIFO\Terminal\TerminalId,
Right(strComputer, 2), "REG_SZ"

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--



My System SpecsSystem Spec
Old 07-27-2009   #2 (permalink)
Stefan Kanthak


 
 

Re: Update registry with part of Computers Name

"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote:

Your address is still invalid!
Quote:

> Assuming the script is run on the computer, one solution could be:
> ========
> Option Explicit
> Dim objNetwork, strComputer, objShell
>
> ' Retrieve NetBIOS name of computer.
> Set objNetwork = CreateObject("Wscript.Network")
> strComputer = objNetwork.ComputerName
>
> ' Assign value in local registry.
> Set objShell = CreateObject("Wscript.Shell")
> objShell.RegWrite "HKLM\Software\LOCDES\SYSIFO\Terminal\TerminalId,
> Right(strComputer, 2), "REG_SZ"
If this doesn't has to be written in VBScript, consider following one-liner:

REG.EXE ADD "HKLM\Software\LOCDES\SYSIFO\Terminal" /v "TerminalId" /t REG_SZ /d "%COMPUTERNAME:~-2" /f

Stefan

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Retrieve Remote Registry Key from netowrk computers PowerShell
Won't start after update download...first part Vista installation & setup
turn off remote computers - part 2 PowerShell
Update or Instal Vista fails "Windows could not update registry da Vista General
Install fail at Testing Computers Performance part Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46