Sign in to follow this  
Followers 0
jteylingen

Need help with startup-script to create a local group

1 post in this topic

Hello,

I'm a newby with AutoIt and I want to use AutoIt to do the following things in a startup script:

  • Check if a local user exist
  • If Not Create this User
  • If User exist only change the password (if necessary)
  • Check if a local group exist
  • If Not Create this group
  • Add the created user to this group
With some cut and paste work I've created a script which is able to check the user and create this user. It also can add a user to an existing group and it can change the password. The only thing I cannot resolve is to create a new local group.

This is the scipt I have so far:

;#include <GUIConstants.au3>

; RETRIEVE Computer Name

Dim $objNetwork, $strComputerName

$objNetwork = ObjCreate("WScript.Network")

$strComputer = $objNetwork.ComputerName

$strUserName = ("username")

$strFullName = ("User Fullname")

$strPassword = ("Password")

$strGroup = ("group")

$objUser = ObjGet("WinNT://" & $strComputer & "/" & $strUserName)

If @Error then

; Code To add User

$objSystem = ObjGet("WinNT://" & $strComputer)

$objUser = $objSystem.Create("user", $strUserName)

$objUser.FullName = $strFullName

$objUser.SetPassword ($strPassword)

$objUser.Put ("Description", "Local Useraccount for blabla")

$objUser.SetInfo

$objGroup = ObjGet("WinNT://" & $strComputer & "/" & $strGroup)

If @Error Then

$objSystem = ObjGet("WinNT://" & $strComputer)

$objGroup = $objSystem.Create("group", $strGroup)

$objGroup.Put ("Description", "Local Group for blabla users")

EndIf

; Code to add User to Group

$objGroup.Add("WinNT://" (& $strComputer & "/" & $strUserName))

Else

$objUser.SetPassword ($strPassword)

EndIf

Exit

Who can help me with this issue?

Gr. Jteylingen

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0