jben Posted April 11, 2008 Share Posted April 11, 2008 Hey everyone. I've been working on a bit of code that automates a piece of software, however within this code i'm trying to work out how I can change the computer name based on information in the BIOS. I found this utility called compname.exe which looks interesting but cant find enough information on it. I feel that I may need to import a runonce reg file from within AutoIT and then upon next login the runonce reg file will run and call compname.exe Something like the following for runonce "%systemdrive%\apps\rename\compname.exe /c ?s" /f and then during my AutoIT installation i can copy a file to the above specified folder. Anyone have any ideas on this? many thanks Link to comment Share on other sites More sharing options...
Developers Jos Posted April 11, 2008 Developers Share Posted April 11, 2008 Why would you want to create a RunOnce in stead of just doing a FileInstall() for Compname.exe and then just running it? _RunDOS("COMPNAME /c " & $NEWPCNAME) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
LarryDalooza Posted April 11, 2008 Share Posted April 11, 2008 WMI can get bios info and other info... There are many ways render a kitten skinless. Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
jben Posted April 11, 2008 Author Share Posted April 11, 2008 can WMI get bios information and use something from the BIOS to change the PC name though?....Trying to figure out how I could implement this. thanks Link to comment Share on other sites More sharing options...
spudw2k Posted April 11, 2008 Share Posted April 11, 2008 can WMI get bios information and use something from the BIOS to change the PC name though?....Trying to figure out how I could implement this.thanksYou can query info from the WMI class Win32_BIOS, but really the only truly "unique" info you'd get would be a serial number. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Kerros Posted April 11, 2008 Share Posted April 11, 2008 (edited) This is how I change the ComputerName under XP using the SN# of my Dell systems. $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems $Output = $objItem.IdentifyingNumber next RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName","ComputerName","REG_SZ" ,$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters","Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$Output) Regwrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Tcpip\Parameters","Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Output) Edited April 11, 2008 by Kerros Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
jben Posted April 11, 2008 Author Share Posted April 11, 2008 Cheers but what sort of code is that. AutoIT?....Because I pasted in AutoIT and it chucked an error back at me.. This is how I change the ComputerName under XP using the SN# of my Dell systems. $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems $Output = $objItem.IdentifyingNumber next RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName","ComputerName","REG_SZ" ,$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters","Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$Output) Regwrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Tcpip\Parameters","Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog","ComputerName","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","Hostname","REG_SZ",$Output) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Output) Link to comment Share on other sites More sharing options...
Kerros Posted April 11, 2008 Share Posted April 11, 2008 (edited) Copy the code above again. That code is just a small part of a larger script... I added some constants above. Edit: Sorry about missing the constants. Also remember as they are registry changes you will need to reboot to make them active. Kerros Edited April 11, 2008 by Kerros Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
jben Posted April 11, 2008 Author Share Posted April 11, 2008 Thats interesting. Just tried it on my PC and then restarted and the PC just looped and looped until i choose last known good configuration. I am using Vista with this though, maybe it doesn't work with Vista??....Not a problem as I want to use this on XP and 2K but doesn't seem to work on vista for some reason Link to comment Share on other sites More sharing options...
Kerros Posted April 11, 2008 Share Posted April 11, 2008 I've never tried changing the computer name in vista, as this script was originally written to allow for ghosted images to change the computer name so that there is never more then one on the network. Vista doesn't seem to care if the systems have the same name so I didn't Put this portion of the script into my Vista images. Kerros Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
jben Posted April 11, 2008 Author Share Posted April 11, 2008 Ok no problem. I will try this out on Win 2k and XP soon. Is it possible to fix some text before the serial? as in PC-serialinfo Link to comment Share on other sites More sharing options...
Kerros Posted April 11, 2008 Share Posted April 11, 2008 Sure just do the following after the for loop $output = 'PC-Serial:'&$output Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
jben Posted April 11, 2008 Author Share Posted April 11, 2008 Not sure where to stick that code. Do you mean: For $objItem In $colItems $output = 'PC-Serial:'&$output next Link to comment Share on other sites More sharing options...
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