Page 1 of 1 1
Topic Options
#102032 - 2003-06-11 12:25 AM Rename workstation
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Hello all

I have 70 new computers arrived for installation of w2k and NT4, I created two clean images(power quest image) and automated to install it by a network boot floppy.

Now all machines are in eork group with the same name I curius to know is there any script available to rename this pc's and join domain by one run ?

Thanx in advance.
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#102033 - 2003-06-11 03:34 AM Re: Rename workstation
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
NT Doc posted a thread about using NETDOM to do that... about a week or 2 ago
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#102034 - 2003-06-11 04:28 AM Re: Rename workstation
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Saleem,

Here is a post I made using KiXforms with NETDOM to MOVE computers into an AD.

The current code does not support renaming a computer, but can be modified to do so.

Take a look at how the code works and modify it to complete the task your looking to do.

It is possible to do this without KiXforms, but harder to implement. I had to use some different array code and methods to hide the password, etc... without KiXforms.

http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=004394

[ 11. June 2003, 04:29: Message edited by: NTDOC ]

Top
#102035 - 2003-06-11 03:08 PM Re: Rename workstation
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
It looks cool
I'll give it a try and let you know.
where can I get the updated one ?
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#102036 - 2003-06-11 06:40 PM Re: Rename workstation
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Saleem, you just copy the code that is posted and put it into a text file and save it as some file name .kix

Download the latest beta of KiXforms as the other post shows and install the KIXFORMS.DLL

Download the NETDOM.EXE program as well
I copy all the required files into the same directory because for my current usage it is all run from a floppy disk.

Then using KiXtart v4.21 do something like

KIX32.EXE FILENAME.KIX and it should run the form.

As far as having it RENAME a computer, the code currently DOES NOT do that.

You can modify the code to do it though. I may do it myself in a week or so if I have time, but right now I'm working on other projects and don't have time to update the code for that purpose.

Top
#102037 - 2003-06-12 03:55 PM Re: Rename workstation
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
I found a vbscript from http://www.swynk.com/ to rename the PC and join to domain

It requires NTDOM.exe SHUTDOWN.EXE and SScrRun.dll, This DLL need to be registered.

It works fine in NT4 I made some changes for W2K but still it is giving some problems sometime, ast time it do the job otherwise it'll just rename the PC but dosent join to domain

Since I am not expert in VBscripting I am submitting this one to you for review.

If somebody can convert it to KIX it would be very nice

code:
Option Explicit

Dim objRegistry, objRegRem, objValue, OldPCName, NewPCName, oWshShell, test, Command

OldPCName = InputBox("Type in the PC you wish to rename")
NewPCName = InputBox("Type in the new name of the PC")

Set objRegistry = CreateObject("RegObj.Registry")
Set objRegRem = objRegistry.RemoteRegistry(OldPCName)
Set oWshShell = CreateObject("WScript.Shell")


RemoveDomain()
EditValueComputerName()
EditValueParameters()
Reboot()
JoinDomain()

Function RemoveDomain()
oWshShell.Run "netdom.exe MEMBER \\" & OldPCName & " /joinworkgroup workgroup", 1, TRUE
End Function

Function EditValueComputerName()
Set objValue = objRegRem.RegKeyFromString("\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName")
objValue.Values.Remove ("ComputerName")
objValue.Values.Add "ComputerName", NewPCName,1 'Recreates value with new pc name
End Function

Function EditValueParameters()
Set objValue = objRegRem.RegKeyFromString("\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters")
objValue.Values.Remove ("Hostname")
objValue.Values.Add "Hostname", NewPCName,1 'Recreates value with new pc name
Set objValue = objRegRem.RegKeyFromString("\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters")
objValue.Values.Remove ("NV Hostname")
objValue.Values.Add "NV Hostname", NewPCName,1 'Recreates value with new pc name
End Function

Function JoinDomain()
If reachable(NewPCName) then
oWshShell.Run "netdom.exe /domain:mydomain MEMBER " & NewPCName & " /ADD", 1, TRUE 'Edit DOMAIN with the proper domain PC is to be a part of
command = "net use \\" & NewPCName & "\ipc$ /user:" & NewPCName & "\administrator password" 'Edit PASSWORD with either the local administrator password or replace administrator with a local admin account followed by the password
oWshShell.Run command, 1, TRUE
command = "netdom.exe /domain:mydomain MEMBER " & NewPCName & " /JOINDOMAIN" 'Edit DOMAIN with the proper domain PC is to be a part of
oWshShell.Run command, 1, TRUE
Else
JoinDomain()
End If
End Function

Function Reboot
oWshShell.Run "SHUTDOWN.EXE \\" & OldPCName & " /r /t:01 /c /y", 1, TRUE
End Function

function reachable(HostName)
dim wshShell, fso, tfolder, tname, TempFile, results, retString, ts
Const ForReading = 1, TemporaryFolder = 2
reachable = false
set wshShell=wscript.createobject("wscript.shell")
set fso = CreateObject("Scripting.FileSystemObject")
Set tfolder = fso.GetSpecialFolder(TemporaryFolder)

'-w 100000 is 5 mins worth of timeout to cope with establishing a dialup
wshShell.run "cmd /c ping -n 4 -w 10000 " & HostName & "> tempfile.txt" ,0,true
set results = fso.GetFile("tempfile.txt")
set ts = results.OpenAsTextStream(ForReading)
do while ts.AtEndOfStream <> True
retString = ts.ReadLine
if instr(retString, "Reply")>0 then
reachable = true
exit do
end if
loop
ts.Close
results.delete
end function

I am more comferteble in KIx rather VB Script.
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 883 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.127 seconds in which 0.064 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org