Replace Registry (REG_SZ) keys at first login with current OS name?

Posted on 2007-08-11
Medium Priority
Last Modified: 2009-07-29

I need to have a script run (at first login) after a new OS is built that does the following:

1)  Delete the following two REG_SZ keys (located here):


Keys are:

'Browser' and

^^ These two keys contain a text value for the 'old' pre-image OS name

2)  I then need to re-add these keys with the 'new' current system (OS) name (guessing by passing in %COMPUTERNAME% somehow)?

If there is a way to replace the current value of these keys instead of deleting / re-adding that works as well.

Operating Systems this will be used on:

Windows 2003 Server Standard (32-bit and 64-bit)
Windows 2003 Server Enterprise (32-bit and 64-bit)

Thank you in advance!!
Question by:EEK2
  • 2
LVL 14

Expert Comment

ID: 19677629
:: *** delreg.cmd
@echo off
set w=echo.^>^>%temp%\delreg.tmp
if exist %temp%\delreg.tmp del %temp%\delreg.tmp
::registry file creation
%w% Windows Registry Editor Version 5.00
%w% [HKEY_LOCAL_MACHINE\Software\VERITAS\NetBackup\CurrentVersion\Config]
%w% "Browser"=-
%w% "Client_Name"=-
regedit /s %temp%\delreg.tmp
::end delreg.cmd

:: *** setreg.cmd
@echo off
set w=echo.^>^>%temp%\setreg.tmp
if exist %temp%\setreg.tmp del %temp%\setreg.tmp
::registry file creation
%w% Windows Registry Editor Version 5.00
%w% [HKEY_LOCAL_MACHINE\Software\VERITAS\NetBackup\CurrentVersion\Config]
%w% "Browser"="%COMPUTERNAME%"
%w% "Client_Name"="%COMPUTERNAME%"
regedit  /s %temp%\setreg.tmp
::end setreg.cmd

LVL 14

Accepted Solution

canali earned 2000 total points
ID: 19677653
reg delete HKEY_LOCAL_MACHINE\Software\VERITAS\NetBackup\CurrentVersion\Config /v Browser /f
reg delete HKEY_LOCAL_MACHINE\Software\VERITAS\NetBackup\CurrentVersion\Config /v Client_Name /f

reg add HKEY_LOCAL_MACHINE\Software\VERITAS\NetBackup\CurrentVersion\Config /t REG_SZ /v Browser /d %computername% /f
reg add HKEY_LOCAL_MACHINE\Software\VERITAS\NetBackup\CurrentVersion\Config /t REG_SZ /v Client_Name /d %computername% /f

Author Comment

ID: 19679321
Perfect solutions, Canali -- thank you very much.

In terms of the two different options -- would you recommend one as being more resilient than another (i.e. more portable between W2K and W2K3) or is it a wash?

I personally liked the last one because it seemed to achieve the result with less complexity...

Thanks, again.

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

840 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