Bu script sayesinde bilgisayar üzerinde yeni bir local user account yaratılmış, bu local user account’a bir password atanmış ve account ilgili gruba member edilmiş olur. Bununla birlikte account için “password never expires” ayarıda enable olur yani password süresiz olarak geçerlidir.

Script içerisinde strAccount, strPswd ve son bölümdeki Set objGroup satırında grup bilgisini düzenlemeyi unutmayın.

' specify account to create
strAccount = "Ozgur"
strPswd = "123456"

' get local computer name
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

' check if local account already exists
intExists = 0
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
    If objUser.Name = strAccount Then
     intExists = 1
  End If
Next

If intExists = 0 Then
   ' create local user
   Set colAccounts = GetObject("WinNT://" & strComputer & "")
   Set objUser = colAccounts.Create("user", strAccount)

   ' set pswd
   objUser.SetPassword strPswd
   objUser.SetInfo

   ' set pswd never expires
   Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",User")
   objUserFlags = objUser.Get("UserFlags")
   objPasswordExpirationFlag = objUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
   objUser.Put "userFlags", objPasswordExpirationFlag
   objUser.SetInfo

   ' add to local admins group
   Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
   Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
   objGroup.Add(objUser.ADsPath)
End If
teknolojikadam.com'da şu an 21 ziyaretçi geziniyor. Toplam 67 yazı, 29 yorum var