Jump to content
Sign in to follow this  

Need help with startup-script to create a local group

Recommended Posts



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")


$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")


; Code to add User to Group

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


$objUser.SetPassword ($strPassword)



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