jteylingen Posted April 15, 2008 Posted April 15, 2008 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 existIf Not Create this UserIf User exist only change the password (if necessary)Check if a local group existIf Not Create this groupAdd the created user to this groupWith 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 NameDim $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)EndIfExitWho can help me with this issue?Gr. Jteylingen
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now