Jump to content

change computername


 Share

Recommended Posts

Is there a quick way to change a computername with autoIt script?

(I need to have the computername equal as the loged on user.

so something like @computername = $userid

(pay attention that I use the userid as written in the registry, cause my script runs as a service, otherwise I have 'system' as user.

Link to comment
Share on other sites

Is there a quick way to change a computername with autoIt script?

(I need to have the computername equal as the loged on user.

so something like @computername = $userid

(pay attention that I use the userid as written in the registry, cause my script runs as a service, otherwise I have 'system' as user.

if u want the real suer name use @username = @computername

$test = @username = @computername

MsgBox(0, "test", $test)

not tested

Link to comment
Share on other sites

Have a look at This article from Microsoft

;) I hope he means to rename the My Computer icon, and not the computer, after the current user name... cause that's just... :)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The machine name can also be changed using WMI.

Here's a link to a Microsoft page where I found out how to do it: from http://msdn2.microsoft.com/en-us/library/aa393056.aspx

See attached file for sample functions.

There are four functions in the file:

Computer_Rename( $sComputerName, $sLocalUser, $sPassword )

Computer_AddToDomainOrWorkgroup( $sDomain, $sDomainUsername, $sPassword )

Computer_RemoveFromDomain( $sDomainUsername, $sPassword )

Computer_MemberOfDomainOrWorkgroup( )

Enjoy!

Func_Computer.au3

Link to comment
Share on other sites

hmm, is not working.

I did the script

first showed current computername

change computername to another

showed new computerame. (but it's still the same)

also after a gpforce /update the name hasn't changed.

And yes it is indeed needed for a project that the computername changes to the name of the user logged on to it.

(registry value also didn't seemed to work)

and it need to be done without installing extra components in windows.

thx for your support and help so far, but it wasn't correct. Please any other idea or suggestion

Link to comment
Share on other sites

And yes it is indeed needed for a project that the computername changes to the name of the user logged on to it.

Don't have an answer, but occurs to me that since the computername is used by many services that start before logon, a change to the computername almost certainly requires a reboot. (and hence user-logoff) Thus, is the scheme feasible anyway?

An alternative might be to change the computer's descriptive text. Would that be of any use?

Link to comment
Share on other sites

The script below is what I use to rename the computer name.

_RenameComputerName($userid)

Func _RenameComputerName($sComputerName)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName", "ComputerName","REG_SZ", $sComputerName) Then Return(1)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $sComputerName) Then Return(1)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $sComputerName) Then Return(1)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $sComputerName) Then Return(1)
    Return(0)
EndFunc
Just to let you know after using the script you need to reboot otherwise you still see the old computername.

Note: I don't know what you project is about, but once you rename the computer if the computer belong to a domain you won't be able to log back in using any user account. The only way to login is using the administrator account only.

xwing1978 nice scirpt thank you for sharing. The only thing is Computer_AddToDomainOrWorkgroup( ) Computer_RemoveFromDomain() wmi won't work in windows 2000.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...