$name = "COMPUTERNAME" $workgroup = "WORKGROUP" $restart = 0 ;0 = no restart, 1 = restart Run("control sysdm.cpl,,1 -1") ;Launch System Properties Page WinWait("System Properties") ;Wait for the page to exist WinActivate("System Properties") ;Activate it (it should be already, but just in case) ControlClick("System Properties","","&Change...") WinWait("Computer Name Changes") WinActivate("Computer Name Changes") ;Activate it just in case ControlSetText("Computer Name Changes","","Edit1",$name) ;Change computer name ControlSetText("Computer Name Changes","","Edit4",$workgroup) ;Change workgroup ControlClick("Computer Name Changes","","OK") WinWaitNotActive("Computer Name Changes","You can change the") ;Wait for something else to take focus WinWaitActive("Computer Name Changes","Welcome to the",5) ;Wait for new workgroup dialog box If WinActive("Computer Name Changes","Welcome to the") Then ControlClick("Computer Name Changes","Welcome to the","OK") ;If the new workgroup dialog pops up click OK EndIf WinWaitActive("Computer Name Changes","You must restart") ControlClick("Computer Name Changes","You must restart","OK") WinWaitActive("System Properties") ;Wait for System Properties to come back to focus ControlClick("System Properties","","OK") WinWait("System Settings Change") WinWaitActive("System Settings Change","You must restart your") If $restart Then ;Pick the restart option ControlClick("System Settings Change","","&Yes") Else ControlClick("System Settings Change","","&No") EndIf
Set the 3 variables at the top, $name, $workgroup, and $restart. The name and workgroup should be pretty obvious, the restart options just controls whether or not the script answers yes or no to the "Would you like to restart your computer" prompt that pops up after you rename your computer.
No comments:
Post a Comment