Sign in to follow this  
Followers 0
mikeylikesit

Renaming a Computer

17 posts in this topic

Hey, I am new to autoit, and i love it! At the place that i work we need to change the names of computers quite often. i need a way to it in autoit. This is what i have:

"$newname=InputBox ("Rename Computer", "Enter New Name: ", @ComputerName)"

i was hoping i would be able to type in a REGWRITE to change the name of the computer but thats not working because i can find the value on the registry Can someone help me.

All i need is a Prompt like what i have above that will change the name of the computer.

any help would be great thanks

Mike


Hard work never killed anyone but why take the chance?

Share this post


Link to post
Share on other sites



HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

i tried that, with no luck i can modify that but it does not show up under the "computer name" in my computer thanks for the help though


Hard work never killed anyone but why take the chance?

Share this post


Link to post
Share on other sites

i tried that, with no luck i can modify that but it does not show up under the "computer name" in my computer thanks for the help though

It works... Kinda have to restart :whistle:

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

i have tried this on windows xp pro as well as windows xp media center with no luck what am i doing wrong. i navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName

i then modify "Computer name" to w/e i want and restart. on the restart the change will show up in regedit but not in my computer.


Hard work never killed anyone but why take the chance?

Share this post


Link to post
Share on other sites

i have tried this on windows xp pro as well as windows xp media center with no luck what am i doing wrong. i navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName

i then modify "Computer name" to w/e i want and restart. on the restart the change will show up in regedit but not in my computer.

Try changing this one:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

still not working, dont worry about it but if it ever crosses your mind let me know

Thanks For the help

Mike


Hard work never killed anyone but why take the chance?

Share this post


Link to post
Share on other sites

still not working, dont worry about it but if it ever crosses your mind let me know

Thanks For the help

Mike

I just used the one above on 98 se and xp pro sp2 and it worked... no idea why it's not working for you.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I tried to... and no name changes happened here


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

I found another place where the "old" name is mentioned

HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam

HKEY_CURRENT_USER\Software\Microsoft\Windows Media\WMSDK\General

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Tcpip\Parameters

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Services\Tcpip\Parameters

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\ShellNoRoam

HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\ShellNoRoam

And stopped there.... might be more places


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

You might try using a tool that tracks registry changes or compares them. Then make the appropriate changes in the registry with your script.

If there is a domain controller that the computer uses to authenticate the present user then you will have to add more steps, like first starting by logging on to the local machine, then changing the name. You usually will get prompted for the user that has rights to change the computer name (A domain Admin). Then a reboot is required to be re-registered on the domain.

I think there are a few VB scripts on the net that do this, examine them and see what the steps are.

Hope this expands your options.

Share this post


Link to post
Share on other sites

Ya'll are making me lose my mind, I just tried it on 4 operating systems now (have to restart :whistle: ) and they all worked.

Dim $var = 'HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\', $Value
While $Value = ''
    $Value = InputBox('Change Computer Name', 'Change Below')
WEnd
RegWrite($var, 'ComputerName', 'REG_SZ', $Value)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

You only need to change two registry key and reboot.

The first one SmOke_N give it to you.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName

and the second one is

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

You only need to change two registry key and reboot.

The first one SmOke_N give it to you.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName

and the second one is

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname

Yeah, but I don't think you have to change the tcpip hostname to change the computer name (at least I never have in the past). Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

You might try using a tool that tracks registry changes or compares them. Then make the appropriate changes in the registry with your script.

If there is a domain controller that the computer uses to authenticate the present user then you will have to add more steps, like first starting by logging on to the local machine, then changing the name. You usually will get prompted for the user that has rights to change the computer name (A domain Admin). Then a reboot is required to be re-registered on the domain.

I think there are a few VB scripts on the net that do this, examine them and see what the steps are.

Hope this expands your options.

I used the two regitry key in post #13 to change 1200 computer names in a domain.

These are the step that I follow.

1) Remove the computer from the domain into a workgroup

2) Use the above registry key to change computer name

3) Set the computer to autologon into administrator account. Optional changed administrator password.

4) Reboot

5) Run Netdom to join domain. I use Netdom because we have multiple OS (Winnt, Win2k and WinXp) to join domain using vb script only work in WinXP.

6) Remove autologon

7) Reboot

done. Good luck....


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

@mikeylikesit

Maybe this can give you a start.

Dim $strComputer, $objWMIService, $colComputers, $objComputer, $strName
$strComputer="."

 $objWMIService=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
 $colComputers=$objWMIService.ExecQuery("Select $* $from Win32_ComputerSystem")
For $objComputer in $colComputers
$Err = $objComputer.Rename ("NewNme")
Next

This might be usefull as well.

Computer Rename Tool

Haven't tested it though.

Enjoy !!

ptrex

Share this post


Link to post
Share on other sites

Hey, I am new to autoit, and i love it! At the place that i work we need to change the names of computers quite often. i need a way to it in autoit. This is what i have:

"$newname=InputBox ("Rename Computer", "Enter New Name: ", @ComputerName)"

i was hoping i would be able to type in a REGWRITE to change the name of the computer but thats not working because i can find the value on the registry Can someone help me.

All i need is a Prompt like what i have above that will change the name of the computer.

any help would be great thanks

Mike

Here is a bit of code that I am currently using in a project. It works fine. The machine does need rebooted after this is ran for the changes to show.

Func Rename($name)
    RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName", "ComputerName","REG_SZ", $name)
    RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $name)
    RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $name)
    RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $name)
    Return 0
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0