.:++ Me+MySelf & I ++:.

dari dalam diri seorang aku..

Join Domain Script [revised] June 13, 2007

Filed under: Windows — asriey @ 6:31 pm

Selepas membuat beberapa pembaharuan, ini adalah versi yang terkini. Apa yang skrip ni bleh buat ialah:

  1. Rename PC
  2. Masukkan description
  3. Join Domain

Dim objWMIService, colComputers, objComputer, strComputer, objRegistry
Dim strKeyPath, strValueName, strDescription
Dim strDomain, strPassword, strUser, namaPc
Dim NewName, Result

set objNetwork = CreateObject("Wscript.Network")
namaPc=objNetwork.ComputerName
NewName = InputBox("Enter a new name for this computer:","Rename Computer", namaPc)

NewName = Trim(NewName)
If NewName = "" Then WScript.Quit(10)

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!root\cimv2")

Set colComputers = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")

For Each objComputer in colComputers
WScript.Echo "Renaming " & objComputer.Name & " to " & NewName
Result = objComputer.Rename(NewName)
If Result = 0 Then
WScript.Echo "Rename Successful."
Else
WScript.Echo "Failed, error " & Result & "."
End If
Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set objRegistry = GetObject _
("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "System\CurrentControlSet\Services\lanmanserver\parameters"
strValueName = "srvcomment"
strDescription = InputBox("Masukkan Diskripsi Komputer Ini")

objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription

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

strDomain = "nama-domain"
strPassword = "password-ler"
strUser = "user"

Set objNetwork = CreateObject("WScript.Network")

strComputer = objNetwork.ComputerName


Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, strDomain & "\" & strUser, NULL, _
JOIN_DOMAIN + ACCT_CREATE)


If Result = 0 Then
WScript.Echo "Join Domain Successful."
Else
WScript.Echo "Failed, error " & Result & "."
End If
WScript.Quit(Result)

just copy dan paste ke notepad, kemudian save as .vbs. pastu double klik je kalau nak guna. function rename tu bleh buang kalau tak perlu. ianya ada kat situ sbb lepas ghost pc, mesti la nak tukar nama sebelum join domain. kalau pc baru, tak perlu.

 

2 Responses to “Join Domain Script [revised]”

  1. Azam Says:

    Not yet tested … but 4 sure i will test …

  2. Azam Says:

    bro … tak jadik la …
    ada error …

    Windows Script Host
    Line : 12
    Char : 15
    Error : Invalid Character
    Code : 800A0408
    Source : Micro$oft VBSrcipt compilation error


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s