Jump to content

Recommended Posts

I haven't found a way to rename the local computer in AutoIT.  Is there a function available for this?

<{POST_SNAPBACK}>

You can download compname.exe at http://www.willowhayes.co.uk/

It allows you to rename a PC using command line. You can use it in your script to prompt for a Computername and pass the appropriate commandline.

You will have to reboot for the changes to take effect.

Link to post
Share on other sites
  • 1 month later...

hi,

i hope this can help you, i wrote it a few months ago. it changes the computername, and asks if you want to reboot or not.

i think it`s not perfect but it works.

oh, please excuse my bad english....

$name1 = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName"
$name2 = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters"
$name3 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName"
$name4 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"

$rebootok = 0

$actualname = EnvGet("COMPUTERNAME")

$antwort = InputBox ( "Change Computername", "Actual Name: " & $actualname & @CRLF & @CRLF & "Type the new name if you want to change. Needs a reboot to activate.", $actualname, "")

If $antwort = $actualname Then
   $tray_title = "Computername not changed !"
   $tray_prompt1 = "The name ist the same as the actual name."
   $tray_prompt2 = "No change required !"

ElseIf $antwort = "" Then
   $tray_title = "Computername not changed !"
   $tray_prompt1 = "Cancelled"
   $tray_prompt2 = ""

Else
   $antwort2 = MsgBox(36, "Confirm change of Computername", "New Name " & $antwort & " ?")

   If $antwort2 = 6 Then
      RegWrite($name1,"ComputerName","REG_SZ",$antwort)
      RegWrite($name2,"NV Hostname","REG_SZ",$antwort)
      RegWrite($name3,"ComputerName","REG_SZ",$antwort)
      RegWrite($name4,"NV Hostname","REG_SZ",$antwort)
      $reboot = MsgBox(36, "Computername written to system", "Reboot now ?")
         If $reboot = 6 Then
            $rebootok = 1
            $tray_title = "Computername changed !"
            $tray_prompt1 = "Prepare for Reboot."
            $tray_prompt2 = "Name after Reboot: " & @CRLF & $antwort

         ElseIf $reboot = 7 Then
            $rebootok = 0
            $tray_title = "Computername changed !"
            $tray_prompt1 = "No Reboot for now"
            $tray_prompt2 = "Name after Reboot: " & @CRLF & $antwort

         EndIf

   ElseIf $antwort2 = 7 Then
      $tray_title = "Computername not changed !"
      $tray_prompt1 = "Changed your mind ?"
      $tray_prompt2 = "You don`t like " & $antwort & ", hmmmm ?!??!?!?"

   EndIf

EndIf
TrayTip ( $tray_title, $tray_prompt1 & @CRLF & $tray_prompt2,"",1)
sleep (3000)
If $rebootok = 1 Then
Shutdown ( 2 )
EndIf
Edited by sirhc
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...