‎01-06-2015 01:31 PM - last edited on ‎07-04-2023 05:29 PM by ErikT
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)
‎02-11-2015 09:53 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now