faqts : Computers : Operating Systems : Microsoft : bilal

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 7 people (86%) answered Yes
Recently 6 of 7 people (86%) answered Yes

Entry

Microsoft: Windows: XP: How set computername from command line: regedit + 4nt/4dos + one line alias?

Apr 4th, 2006 16:32
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 04 April 2021 - 11:31 pm ----------------------
Microsoft: Windows: XP: How set computername from command line: 
regedit + 4nt/4dos + one line alias?
===
Method: Replace the current registry value for computername
The computername is stored in the registry value:
 HKEY_LOCAL_MACHINE\System\ControlSet001
\Control\Computername\Computername
 or
 HKLM\System\ControlSet001\Control\Computername\
===
Method: Use the program regedit.exe with parameter /s to set a 
registry value
---
Steps: Overview:
 1. -You use the program
      regedit.exe
     1. -With the parameter
          /s
         1. -This needs by design a text file
             (with file extension .reg) to set the
             registry value
             1. -The structure of this .reg file looks like
--- cut here: begin --------------------------------------------------
      REGEDIT4
      [<your path to the registry key (inclusive the registry variable 
name itself)>]
      "<your registry value name>"="<your registry value>"
--- cut here: end ----------------------------------------------------
 2. -What you want to create here is the text file
     (e.g. using the computername JUSTTESTING)
--- cut here: begin --------------------------------------------------
      REGEDIT4
      [HKEY_LOCAL_MACHINE\System\ControlSet001
\Control\Computername\Computername]
      Computername"="JUSTTESTING"
--- cut here: end ----------------------------------------------------
 3. -What you can do is to create a batch file
     which first creates this
     batch file, just by PRINTing
     it (that is using ECHO here)
 4. -Create a batch file
      ddd.bat
 5. -Print the .reg file
--- cut here: begin --------------------------------------------------
 @IF "%1"=="" GOTO empty
 @ECHO REGEDIT4 > ddd.reg
 @ECHO. >> ddd.reg
 @ECHO [HKEY_LOCAL_MACHINE\System\ControlSet001
\Control\Computername\Computername] >> ddd.reg
 @ECHO "Computername"="%1" >> ddd.reg
 regedit /s ddd.reg
 @GOTO end
 :empty
 @echo please supply a non empty new computer name (e.g. mycomputer1) 
>>
 GOTO end
 :end
--- cut here: end ----------------------------------------------------
 6. -But for a (one liner) 4nt/4dos alias you need the following 
(first create the batch file,
     then run that created batch file (e.g. ddd1.bat)), you basically
     also have to PRINT the above.
     So you put in front of the line
     again ECHO, and save it to a batch file.
     After creating you run that batch file.
--- cut here: begin --------------------------------------------------
 @echo @IF "%1"=="" @GOTO empty > ddd1.bat
 @echo REGEDIT4 > ddd2.reg
 @echo. >> ddd2.reg
 @echo [HKEY_LOCAL_MACHINE\System\ControlSet001
\Control\Computername\Computername] >> ddd2.reg
 @echo "Computername"="%1" >> ddd2.reg
 @echo regedit /s ddd2.reg >> ddd1.bat
 @echo @GOTO end >> ddd1.bat
 @echo :empty >> ddd1.bat
 @echo @echo please supply a non empty new computer name (e.g. 
mycomputer1) >> ddd1.bat
 @echo @GOTO end >> ddd1.bat
 @echo :end >> ddd1.bat
 ddd1.bat
--- cut here: end ----------------------------------------------------
 7. -Run this program with parameter your computer name
      ddd.bat <your new computername>
     1. -E.g.
          ddd.bat mynewcomputername1
 8. -If you open your registry and look at your current computername,
     you will live see that it changes to your new computer name
 9. -You will have to restart your computer to activate it globally
10. -To create an alias, you have to put the above on one line.
     So you separate it with the 4nt/4dos line separator
     1. -For a one line alias in 4dos/4nt you could use (here '&' (or 
also use '^') is the line separator).
         Just put the program on 1 line, by concatenating.
      alias computernames*et        @echo @IF "%1"=="" @GOTO empty > 
ddd1.bat & @echo REGEDIT4 > ddd2.reg & @echo. >> ddd2.reg & @echo 
[HKEY_LOCAL_MACHINE\System\ControlSet001
\Control\Computername\Computername] >> ddd2.reg & 
@echo "Computername"="%1" >> ddd2.reg & @echo regedit /s ddd2.reg >> 
ddd1.bat & @echo @echo computername now set to %1 >> ddd1.bat & @echo 
@echo please restart your computer >> ddd1.bat & @echo @GOTO end >> 
ddd1.bat & @echo :empty >> ddd1.bat & @echo @echo please supply a non 
empty new computer name (e.g. mycomputer1) >> ddd1.bat & @echo GOTO 
end >> ddd1.bat & @echo :end >> ddd1.bat & ddd1.bat
===
Note:
-This method can be generalized to set almost any registry value via 
the command line and or with a 4nt/4dos alias.
===
Note:
-Make a backup of your registry before experimenting, and/or try it on 
a virtual machine first
===
Tested successfully on
Microsoft Windows XP Professional (service pack 2),
running
4NT/4DOS v5.x
===
Internet: see also:
---
Network: Proxy: Set: Microsoft: Windows: How to set the proxy server 
via the MSDOS command line?
http://www.faqts.com/knowledge_base/view.phtml/aid/39149/fid/868
---
Operating system: Microsoft: Windows: XP: Link: Overview: Can you give 
an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/34878/fid/868
----------------------------------------------------------------------