Hi everyone, I actually got a vb script recently that allows certain users admin rights on the machine and it works rather well. I was hoping that someone could look at the script and help me with an if.....then statement. Right now, if the user is already an admin on the machine, it gives an error that the account already exists. Here is the script.


Option Explicit

Dim Shell
Set Shell=wscript.createobject("wscript.shell")
Dim fso
Set fso = wscript.CreateObject("Scripting.FileSystemObject")

'On Error Resume Next

Main

If err.number <> 0 then
MsgBox err.description,vbcritical,wscript.scriptname
End If
wscript.quit


Sub main
'--------------------------------------------------------- Main -
Set objNet = CreateObject("WScript.Network") 'new

Dim strUser, StrGroup, oComputer, cuser
Dim oUser, oGroup, sComputerName, objNet, objnetwork, suser

suser = objnet.username
strUser = suser
strGroup = "Administrators"


sComputerName = objNet.ComputerName 'new

Set oComputer = GetObject("WinNT://" & sComputerName)
Set oUser = oComputer.Create ("User", strUser)
On Error Resume Next
Dim strComputer
Dim objWMIService
Dim colItems


oUser.SetPassword "password"
oUser.Put "PasswordExpired", 1
oUser.Fullname = "Fullname"
oUser.Description = "Description"
oUser.SetInfo

Set oGroup = oComputer.GetObject("Group", strGroup)
oGroup.Add(oUser.ADsPath)
oGroup.SetInfo

wscript.echo "User [" & strUser & "] added to[" & strGroup & "] Group"

Set oUser = nothing
Set oGroup = nothing

'-----------------------------------------------------------------
End Sub

Any help would be great!!!!