Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

i think you should search the registry and then regwrite,i am not sure if this is what you want but look at HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\(Default)

Posted

Have a look at This article from Microsoft


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

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

Posted

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

Posted

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?

Posted

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

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...