AutoChris Posted August 15, 2006 Posted August 15, 2006 Does anyone know how to automatically rename a computer using AutoIt? I am using AutoIt for the logon scripts at work and we have recently been told by our parent company that we have to change every computer name in the building to their naming convention. Rather than go to hundreds of computers and manually put in the new computer name, admin name and password, I figured I could do it via logon script. I found a VBS which seems to do it fine, but I was hoping to do it all in AutoIt. I tried the VBS to to AutoIt converter (vaconvert) but that did not work correctly. Any takers? Here is the VBS code: Name = "computername" Password = "password" Username = "administrator" Set objWMIService = GetObject("Winmgmts:root\cimv2") For Each objComputer in objWMIService.InstancesOf("Win32_ComputerSystem") Return = objComputer.rename(Name,Password,User) If Return <> 0 Then WScript.Echo "Rename failed. Error = " & Err.Number Else WScript.Echo "Rename succeeded." & _ " Reboot for new name to go into effect" End If Next
Danny35d Posted August 15, 2006 Posted August 15, 2006 (edited) Sorry, I don't know anything about VBS. I did the same thing for the company that I work for, the only thing I change was a registry key HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName you will need to restart the system for changes take effects.Edit: Typo Edited August 15, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
blademonkey Posted August 15, 2006 Posted August 15, 2006 That's one way of doing it, but then you have to add that computer to the domain.I have a script that does both using the netdom utility from the win2k Resource Kit. You can download it from here:http://www.petri.co.il/download_free_reskit_tools.htmAs for the actual CMD line params, i can't think of them right now since my script is at work. If you don't find them by tommorow morning, be sure to PM me and I'll send it over, or if I remember to post it on this topic i'll do that.it's a pretty straight forward one-liner though and does require reboot, but will automatically join the network (and correctly reset your SMS 2k3 client config).-Blademonkey ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung
Danny35d Posted August 15, 2006 Posted August 15, 2006 blademonkey you are totally right, I forgot all about that. I did my script with WinBatch early 2003. I also used netdom, after renaming the computer I move the computer from one domain into another one. I just look at my WinBatch script and I remember that I have problem using NETDOM. For some reason that I cann't remember I have to use the three version of netdom. First check the computer OS (NT, 2K, XP) and depending the OS I will use that OS NETDOM version.Note: I think NETDOM wasn't back compatible... AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
blademonkey Posted August 15, 2006 Posted August 15, 2006 ya, the NT4 NEtdom would not allow you to add computers to a win2k mixmode or native domain. That's why i linked to the win2k res kit. I'm not sure of a third version of netdom, perhaps its for win2k3 ? in anycase, whenever you do any kind of renaming, you should TEST TEST TEST. always always always. Servers and Productions machines should usually be done by hand, just to make sure that there's no IP or name conflicts. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung
Eric Chang Posted August 15, 2006 Posted August 15, 2006 Does anyone know how to automatically rename a computer using AutoIt? I am using AutoIt for the logon scripts at work and we have recently been told by our parent company that we have to change every computer name in the building to their naming convention. Rather than go to hundreds of computers and manually put in the new computer name, admin name and password, I figured I could do it via logon script.I have almost the same trouble now . I need to fill the Computer Descriptionevery single Computer in my Office.I know how & where to change the registry key , But I dont want manually fill all computersso I make a table which mapping the Computer Name & Comptuer DecriptionlikeCom_Name Com_DescAAA AAA03BBB BBB02CCC CCC15But I have no idea how to do this automation.In my formulation , I try to load the mapping file , and get the hostname from WinXP Variables to determinecom_DEsc in the mapping file .yes, I can read the file , I can get the %hostname% , But I dont know how to match the Com_name in the file , Could anybody kindly help me ?
Eric Chang Posted August 15, 2006 Posted August 15, 2006 Does anyone know how to automatically rename a computer using AutoIt? I am using AutoIt for the logon scripts at work and we have recently been told by our parent company that we have to change every computer name in the building to their naming convention. Rather than go to hundreds of computers and manually put in the new computer name, admin name and password, I figured I could do it via logon script.I have almost the same trouble now . I need to fill the Computer Descriptionevery single Computer in my Office.I know how & where to change the registry key , But I dont want manually fill all computersso I make a table which mapping the Computer Name & Comptuer DecriptionlikeCom_Name Com_DescAAA AAA03BBB BBB02CCC CCC15But I have no idea how to do this automation.In my formulation , I try to load the mapping file , and get the hostname from WinXP Variables to determinecom_DEsc in the mapping file .yes, I can read the file , I can get the %hostname% , But I dont know how to match the Com_name in the file , Could anybody kindly help me ?
blademonkey Posted August 15, 2006 Posted August 15, 2006 Wow that's a doozy, that's going to require some crazy for loop but that depends one which route you go. you can do it in DOS, VBS or AUtoit. I can only help you with the DOS portion of it. First and formost, get PSEXEC from the PSTOOLS suite. you can get them at Sysinternals (better get them quick while they are still free). once you download them, make sure you add them to your %systemroot%\system32 folder ( or an equivalent folder that's in your env path) Note: you only need to download and copy these tools on ONE PC that is going to admin the other clients. let me know when you get that far. might want to familiarize yourself with PSEXEC.exe ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung
Eric Chang Posted August 15, 2006 Posted August 15, 2006 Wow that's a doozy,that's going to require some crazy for loop but that depends one which route you go. you can do it in DOS, VBS or AUtoit.I can only help you with the DOS portion of it.First and formost, get PSEXEC from the PSTOOLS suite. you can get them at Sysinternals (better get them quick while they are still free). once you download them, make sure you add them to your %systemroot%\system32 folder ( or an equivalent folder that's in your env path)Note: you only need to download and copy these tools on ONE PC that is going to admin the other clients.let me know when you get that far.might want to familiarize yourself with PSEXEC.exeI had already use pstools for years.and I am really wondering how do you make pstools to solve this problem .
Danny35d Posted August 15, 2006 Posted August 15, 2006 (edited) @eric Chang Did you try using an ini file instead of a text file?Ex:[Com_Name]AAA = AAA03BBB = BBB02CCC = CCC15For the script all you need is:$Description = IniRead (ComputerList.ini, "Com_Name", $HostName, "If hostname is not on the list, default description" )Edit: Typo Edited August 15, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now