Sign in to follow this  
Followers 0
KatoXY

Create local User

3 posts in this topic

Hi,

I want write script which create local user with password and add it to administrators group. I found in forum this:

; Init objects
;$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler 
$UserName = 'Fred'
$Password = 'Wilma123'
$strComputer = @ComputerName
;***********************
;Create UserID
$colAccounts = ObjGet("WinNT://" & $strComputer & "")
$objUser = $colAccounts.Create("user", $UserName)
$objUser.SetPassword ($Password)
$objUser.Put ("Fullname", "Test User")
$objUser.Put ("Description", "Test User description")
$objUser.Put ("PasswordExpired", 1)  ;expire the password
$objUser.SetInfo
;***********************
;Add User to group 
$objGroup = ObjGet("WinNT://" & $strComputer & "/Administrators,group")
$objGroup.Add($objUser.ADsPath)

It's created 4 years ago and it's working on Windows XP, but it doesn't working in Windows 7 (I have 64bits version).

Where is problem?

Share this post


Link to post
Share on other sites



Where is problem?

Don't know :unsure:

You must provide more information!

What error message do you get? Which line number returns the error?

Please see function "ObjEvent" in the help file to insert a COM error handler (starting from line "; COM Error Handler example") in your script which will deliver detailed error messages.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I added rest of the script from with ObjEvent then I got Access Denied.

When I compiled this script and run as administrator then program has executed the desired operations.

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