cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Bert_D
Lansweeper Employee
Lansweeper Employee

Creates a new local user and adds it to the local admin group

Rem: You need to add the user and password as a parameters.
Rem: If you do not add a username parameter, the username is default set to: Lansweeperadm
Rem: If you do not add a password parameter, the password is default set to: Strongpassword0*

Rem: Copy the code below and save it as Create_Admin_User.vbs at the {PackageShare}\Scripts folder


Set Arg = WScript.Arguments

if Arg.count = 2 then
strUser = Arg(0) 'Pass the username as parameter to the script
strPassword = Arg(1) 'Pass the password as parameter to the script
end if

if IsEmpty(strUser) or IsNull(strUser) or strUser = "" or IsEmpty(strPassword) or IsNull(strPassword) or strPassword = "" then
strUser = "Lansweeperadm"
strPassword = "Strongpassword0*"
end if

Set objWshNet = CreateObject("WScript.Network")
strComputer = objWshNet.ComputerName

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("SELECT Name,SID from Win32_Group where domain ='" & strcomputer & "'")
For Each objItem in colItems
sidAdmin = objItem.SID
if sidadmin = "S-1-5-32-544" then
strGroup = objItem.Name
end if
Next

Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", strUser)
objUser.SetPassword strpassword
objUser.SetInfo
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ",group")
objGroup.Add(objUser.ADsPath)
10 REPLIES 10
gkeys
Engaged Sweeper II
Unfortunately, I am having no success getting this to run on a test machine. Other script installer packages (like change wallpaper) work fine, this one just times out........