Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Set regexp = New RegExp
regexp.Pattern = "\d+\.\d+\.(\d+)\.(\d+)"
ip="192.168.0.1"
iparray = Split(ip,".")
last2 = iparray(2) & "." & iparray(3)
WScript.Echo last2
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
Dim message
Dim IP
strDomain = <DOMAIN NAME>
strUser = <UserName>
strPassword = <ADMIN PASSWORD>
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject ("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
title = "Join computer to domain"
message = "Please enter computer name. Leave blank or press cancel to quit. & vbCrLf & vbCrLf & "Generated name: " & generatedName
newComputerName = InputBox(message, title)
If newComputerName = "" Then
Wscript.quit
End If
areYousure = MsgBox("Are you sure you want t0 add computer to domain with name:" & vbCrLf & vbCrLf & newComputerName, vbYesNo + vbQuestion,"Add computer to domain")
If areYouSure = "7" Then
MsgBox "Exiting script.",vbInformation
Wscript.quit
End If
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strDomain & "\" & strUser, "ou=My_Computer_OU,DC=mycorp,dc=com, _
JOIN_DOMAIN + ACCT_CREATE)
If ReturnValue = 0 Then
MsgBox "Computer added to domain under old name without error. proceeding to change computer name. "
Else
MsgBox "Computer not added to domain successfully. Return value: " & ReturnValue
End If
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
MsgBox "About to rename computer to: " & newComputername
ErrCode = objComputer.Rename(newComputerName, strPassword, strUser)
If ErrCode = 0 Then
MsgBox "Computer renamed correctly."
Else
MsgBox "Eror changing computer name. Error code: " & ErrCode
End If
Next
'==========================================================================
'
' NAME: NetDomJoinWorkstations
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE : 6/24/2003
'
' COMMENT: Joins computers to a new domain. Edit domain name,
' user ID and passwords below. Uses a workstation list wslist.txt.
' Modification 7/28/2003 to include Remove command. Suggest synchronizing old and new server passwords
'
'==========================================================================
On Error Resume Next
'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
For Each strWorkstation In RemotePC
'Do something useful with strWorkstation
Call WSHShell.Run("cmd.exe /c NETDOM REMOVE " & strWorkstation &"/Domain:<domain> /UserD:<user> /PasswordD:<password> UserO:<user> /PasswordO:<password> /REBoot:30000")
Wscript.sleep 15000
Call WSHShell.Run("cmd.exe /c NETDOM JOIN " & strWorkstation &"/Domain:<domain> /UserD:<user> /PasswordD:<password> UserO:<user> /PasswordO:<password> /REBoot:0")
Next
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
Dim message
Dim IP
strDomain = <DOMAIN NAME>
strUser = <UserName>
strPassword = <ADMIN PASSWORD>
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject ("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
title = "Join computer to domain"
message = "Please enter computer name. Leave blank or press cancel to quit. & vbCrLf & vbCrLf & "Generated name: " & generatedName
newComputerName = InputBox(message, title)
If newComputerName = "" Then
Wscript.quit
End If
areYousure = MsgBox("Are you sure you want t0 add computer to domain with name:" & vbCrLf & vbCrLf & newComputerName, vbYesNo + vbQuestion,"Add computer to domain")
If areYouSure = "7" Then
MsgBox "Exiting script.",vbInformation
Wscript.quit
End If
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strDomain & "\" & strUser, "ou=My_Computer_OU,DC=mycorp,dc=com, _
JOIN_DOMAIN + ACCT_CREATE)
If ReturnValue = 0 Then
MsgBox "Computer added to domain under old name without error. proceeding to change computer name. "
Else
MsgBox "Computer not added to domain successfully. Return value: " & ReturnValue
End If
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
MsgBox "About to rename computer to: " & newComputername
ErrCode = objComputer.Rename(newComputerName, strPassword, strUser)
If ErrCode = 0 Then
MsgBox "Computer renamed correctly."
Else
MsgBox "Eror changing computer name. Error code: " & ErrCode
End If
Next