Change Computername And Join Domain

Testing this stuff!

It is also possible to specify user credentials within a script; this enables you to do such things as log on to a computer using a standard user account, yet still run a script that requires administrator privileges. For more information, go to and search for “Creating a WMI Script.”

wbemImpersonationLevelImpersonate = 3
wbemAuthenticationLevelPktPrivacy = 6

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer
("TargetComputer", "root\cimv2", "UserName", "Password")
objService.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
objservices.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy


WMIC.exe is only available under Windows XP Professional, Windows Server 2003, Windows Vista and Windows Server "Longhorn".

wmic /node:"Computer Name (FQDN)" /USER:"username" RDTOGGLE WHERE ServerName="Computer Name" CALL SetAllowTSConnections 1

Rename and joindomainorworkgroup "api" only available on Windows XP. (not 2000)


wmic computersystem CALL joindomainorworkgroup name='NewNameOfWorkgroup' …

For example, we're often asked, "Why doesn't the Join Computer to a Domain script in TechNet's Script Center work on Windows 2000?" The answer is because the Win32_ComputerSystem class (which is the WMI class used in the script) doesn't support the JoinDomainOrWorkGroup method on Windows 2000. The JoinDomainOrWorkGroup method was added to the Win32_ComputerSystem class in the version of WMI built-in to Windows XP and Windows Server 2003.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.