Jump to content
Sign in to follow this  
Tonny

I got a error message, would you help me?

Recommended Posts

Tonny

I Add a user, and I want set the user's property

Code:

$UserName = 'Fred'

$Password = '1234'

$strComputer = @ComputerName

Const $ADS_UF_DONT_EXPIRE_PASSWD = 0x10000

Const $ADS_UF_PASSWD_CANT_CHANGE = 0x40

$objName = "WinNT://" & @ComputerName & "/" & $UserName

$objUser = ObjGet($objName)

$objUserFlags = ObjGet($objUser & ".userFlags")

$objPasswordExpirationFlag = $objUserFlags Or $ADS_UF_DONT_EXPIRE_PASSWD Or $ADS_UF_PASSWD_CANT_CHANGE

$objUser.Put ("userFlags", $objPasswordExpirationFlag )

$objUser.SetInfo

ERROR Message:

D:\My Documents\AutoIt\AddUser.au3 (25) : ==> The requested action with this object has failed.:

$objUser.Put ("userFlags", $objPasswordExpirationFlag )

$objUser.Put ("userFlags", $objPasswordExpirationFlag )^ ERROR

->15:05:08 AutoIT3.exe ended.rc:1

Is anybody known the reason?

Sorry for bay english.

Share this post


Link to post
Share on other sites
Valuater

ObjectCreate() ???

I am not possitive, but quite sure that

$objName = "WinNT://" & @ComputerName & "/" & $UserName

is not an Object.

to use

ObjGet($objName)

You need an object first

8)

Edited by Valuater

NEWHeader1.png

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  

×