Author: Bradly T. BolinPlatform: Windows NT, Windows 2000Type: VBScript This VBS script will remove a workstation from a given NT domain, rename it, and then rejoin it to the domain. Download the script. Scroll down to view the script. ‘========================================================================== ‘ ‘ VBScript Source File ‘ ‘ NAME: computer_rename.vbs ‘ ‘ AUTHOR: Bradly T. Bolin […]
Datamation content and product recommendations are
editorially independent. We may make money when you click on links
to our partners.
Learn More
Author: Bradly T. Bolin
Platform: Windows NT, Windows 2000
Type: VBScript
This VBS script will remove a workstation from a given NT domain, rename it, and then rejoin it to the domain.
Download the script.
Scroll down to view the script.
Option Explicit
Dim oFileSystem
Dim oWshShell
Dim sCurrentName
Dim oWshEnvironment
Dim sTempDir
Dim sPHASE
Dim sProgram
Dim sProgramDir
Set oFileSystem = CreateObject("Scripting.FileSystemObject")
Set oWshShell = CreateObject("WScript.Shell")
Set oWshEnvironment = oWshShell.Environment("Process")
sCurrentName = oWshEnvironment("COMPUTERNAME")
sTempDir = oWshEnvironment("TEMP")
sProgram = "computer_rename.vbs"
sProgramDir = oFileSystem.GetAbsolutePathName(".")
On Error Resume Next
sPHASE = oWshShell.RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonPhase")
Select Case sPHASE
Case ""
Call REMOVE
Case "1"
Call REJOIN
End Select
Dim OpSysSet, OpSys
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys In OpSysSet
OpSys.Reboot()
Next
WScript.Quit
Sub REMOVE
Dim oCompName, oTextStream, sArray, sLine, sNewName
Dim oDictionary
Set oDictionary = CreateObject("Scripting.Dictionary")
Set oCompName = oFileSystem.GetFile(sProgramDir & "" & "compname.txt")
Set oTextStream = oCompName.OpenAsTextStream(1)
Do While Not oTextStream.AtEndOfStream
sLine = oTextStream.ReadLine
sArray = Split(sLine, " = ", -1, 1)
oDictionary.Add sArray(0), sArray(1)
Loop
oTextStream.Close
If oDictionary.Exists(sCurrentName) = FALSE Then
MsgBox("Error")
WScript.Quit
End If
sNewName = oDictionary.Item(sCurrentName)
oFileSystem.CopyFile sProgramDir & "" & sProgram, sTempDir & "" & sProgram
oFileSystem.CopyFile sProgramDir & "" & "NETDOM.EXE", sTempDir & "" & "NETDOM.EXE"
Dim sUserName
sUserName = oWshShell.RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonDefaultUserName")
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonPreviousUser", sUserName
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonPhase", 1
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindowsCurrentVersionRunOnceRUN_RENAME", sTempDir & "" & sProgram
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonAutoAdminLogon", 1
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonDefaultUserName", "XXX"
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonDefaultPassword", "XXX"
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonDefaultDomainName", sNewName
oWshShell.Run sTempDir & "" & "NETDOM.EXE REMOVE " & sCurrentName & " /D:XXX /Ud:XXX /Pd:XXX", 1, TRUE
oWshShell.RegWrite "HKLMSYSTEMCurrentControlSetControlComputerNameComputerNameComputerName", sNewName
oWshShell.RegWrite "HKLMSYSTEMCurrentControlSetServicesTcpipParametersNV Hostname", sNewName
End Sub
Sub REJOIN
Dim sUserName
sUserName = oWshShell.RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonPreviousUser")
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonDefaultUserName", sUserName
oWshShell.RegDelete "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonPhase"
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonAutoAdminLogon", 0
oWshShell.RegDelete "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonDefaultPassword"
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogonDefaultDomainName", "XXX"
Dim sCMD
sCMD = "c:winntsystem32"
oWshShell.RegWrite "HKLMSOFTWAREMicrosoftWindowsCurrentVersionRunOnceRUN_CLEANUP", sCMD & "CMD.EXE /c DEL " & sTempDir & "" & sProgram
oWshShell.Run sTempDir & "" & "NETDOM.EXE JOIN " & sCurrentName & " /D:XXX /Ud:XXX /Pd:XXX", 1, TRUE
End Sub
Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided “as -is”, without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. I shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.
-
Huawei’s AI Update: Things Are Moving Faster Than We Think
FEATURE | By Rob Enderle,
December 04, 2020
-
Keeping Machine Learning Algorithms Honest in the ‘Ethics-First’ Era
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 18, 2020
-
Key Trends in Chatbots and RPA
FEATURE | By Guest Author,
November 10, 2020
-
Top 10 AIOps Companies
FEATURE | By Samuel Greengard,
November 05, 2020
-
What is Text Analysis?
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 02, 2020
-
How Intel’s Work With Autonomous Cars Could Redefine General Purpose AI
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 29, 2020
-
Dell Technologies World: Weaving Together Human And Machine Interaction For AI And Robotics
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 23, 2020
-
The Super Moderator, or How IBM Project Debater Could Save Social Media
FEATURE | By Rob Enderle,
October 16, 2020
-
Top 10 Chatbot Platforms
FEATURE | By Cynthia Harvey,
October 07, 2020
-
Finding a Career Path in AI
ARTIFICIAL INTELLIGENCE | By Guest Author,
October 05, 2020
-
CIOs Discuss the Promise of AI and Data Science
FEATURE | By Guest Author,
September 25, 2020
-
Microsoft Is Building An AI Product That Could Predict The Future
FEATURE | By Rob Enderle,
September 25, 2020
-
Top 10 Machine Learning Companies 2020
FEATURE | By Cynthia Harvey,
September 22, 2020
-
NVIDIA and ARM: Massively Changing The AI Landscape
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
September 18, 2020
-
Continuous Intelligence: Expert Discussion [Video and Podcast]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 14, 2020
-
Artificial Intelligence: Governance and Ethics [Video]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 13, 2020
-
IBM Watson At The US Open: Showcasing The Power Of A Mature Enterprise-Class AI
FEATURE | By Rob Enderle,
September 11, 2020
-
Artificial Intelligence: Perception vs. Reality
FEATURE | By James Maguire,
September 09, 2020
-
Anticipating The Coming Wave Of AI Enhanced PCs
FEATURE | By Rob Enderle,
September 05, 2020
-
The Critical Nature Of IBM’s NLP (Natural Language Processing) Effort
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
August 14, 2020
SEE ALL
APPLICATIONS ARTICLES