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

dari dalam diri seorang aku..

Skrip Join PC ke Domain April 24, 2007

Filed under: Windows — asriey @ 4:22 pm

Biasanya kalau nak join pc ke domain, kita klik kanan pada My Computer->Properties, pastu g pada tab Computer Name, pastu kita klik pada Change, kemendian masukkan nama domain, kemudian akan mintak username dan password admin untuk join domain. pastu kena tunggu beberapa ketika sebelum dapat welcoming message. pastu restart. perhatikan skrip ni:

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"
strUser = "username"

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)

copy skrip diatas dan simpan sebagai nama-fail.vbs. kemudian ubah kat part mana2 yang patut. nama domain, username dan password. siap! untuk memastikan bahawa pc telah terjoin domain, klik kanan pada My Computer->Properties dan tengok pada tab Computer Name, sepatutnya telah join domain dan ada tanda supaya restart pc tersebut.

 

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