Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Network settings script

Status
Not open for further replies.

redlair

Technical User
Jun 29, 2004
54
US
Hello, I am relitivly new to VBScripting. I need a script to promt the user and then change the: computer name, domain\workgroup, static\dhcp, and possibly add a local\domain profile. Can anyone point me to the right pplace to start this project.

Redlair, Thank-You
 
Do some keywords searchs in this forum. This topics already treated in most threads.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I found this script in another thread. I modified it to just rename the computer then join it to the domain. This is for Xp machines. It renames and restarts but does not join the domain.

'==========================================================================
'COPY netdom.exe from the network
'==========================================================================
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "a:\netdom.exe" , "c:\", OverwriteExisting


'==========================================================================
'Pull Current PC Name and Ask for the NEW PC Name
'==========================================================================
Set oWshShell = CreateObject("WScript.Shell")
NewPCname = InputBox("Type in the New PC Name", "Input")
OLDPCName = oWshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName")


'==========================================================================
'Rename the PC
'==========================================================================
oWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName", NewPCname
oWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname", NewPCname

'==========================================================================
'Add the New PC to the Domain
'==========================================================================
Call oWshShell.Run("cmd.exe /c NETDOM JOIN " & NewPCname &"/Domain:str_tis /UserD:xxxx /PasswordD:xxxx UserO:STC /PasswordO:xxxx /REBoot:0")


'==========================================================================
'Reboot the PC
'==========================================================================
MsgBox("Computer Name Change Successfull. Click OK to reboot")

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

 
CompName = WshNetwork.ComputerName
Domain = "DomainName"
DomainName = "XXX"
DomainPass = "Password"

Sub DomainJoin
wshshell.Run "\\mi05dat01\finnish\files\NETDOM.EXE join " & CompName & " /d:" & Domain & " /ud:" &_ DomainName & " /pd:" & strPassword & " /Verbose",1,True

End Sub
 
is it possible to do this without netdom (i.e. 'pure' vbscript/adsi)? i've seen examples of creating computer accounts w/ adsi/vbscript, but nothing that also adds the local computer account.
 
I tried the new script and do not recieve any response. Nothing changes.
 
Here is the whole script. Has to be run on a 2003 server or XP because of the "ScriptPW.Password" This is a XP DLL

Set wshNetwork = CreateObject("WScript.Network")
Set wshShell = CreateObject("wscript.shell")
Set oScriptPW = CreateObject("ScriptPW.Password")

'============Variables=============
DIM CompName
Dim Domain
Dim DomainName
Dim DomainPass
Dim strpassword

CompName = WshNetwork.ComputerName
Domain = "DomanName"
DomainName = "username" '<--hardcode this
DomainPass = ""

'============Sub Routines===========

' Get password for joing domain and connecting to domain resources.
Sub Password
WScript.StdOut.Write "Type password for service account and press the Enter key: "
strPassword = oScriptPW.GetPassword()
WScript.Echo Err.Number
End Sub

' ' Joins workstation to domain. Domain to join and account to used are defined in variables.
Sub DomainJoin
wshshell.Run "\\XXXX\finnish\NETDOM.EXE join " & CompName & " /d:" & Domain & " /ud:" & DomainName & " /pd:" & strPassword & " /Verbose",1,True

End Sub


'===========Script Level Code========
Password
DomainJoin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top