Jump to content

Recommended Posts

Posted (edited)

Hello,

I try to make a program who find properties on a user domain. The problem is on the Expiration Date, When there is one, everything is OK, but when a user does not have a date expiration, the program is interrupted.

$objUser = ObjGet ("WinNT://MYDOMAIN/" & $Login & ",User" )

$UserLogin = $objUser.Name
$UserFullName = $objUser.FullName
$UserProfile = $objUser.Profile
$UserScript = $objUser.LoginScript
$UserDescription = $objUser.Description

[b]$UserExpiration = $objUser.AccountExpirationDate[/b]

Can you help me finding a solution to bypass this error ?

Thank you

:)

Edited by L'egyptien
Posted

As long it's a COM error you can always let one of your own function handle the COM errors. Then you can just ignore it.

Look under the COM section in the help file to see how you register your own error handling function. :)

Broken link? PM me and I'll send you the file!

Posted

Yeah, so if you just want the error to be ignored, this might work:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 

$objUser = ObjGet ("WinNT://MYDOMAIN/" & $Login & ",User" )

$UserLogin = $objUser.Name
$UserFullName = $objUser.FullName
$UserProfile = $objUser.Profile
$UserScript = $objUser.LoginScript
$UserDescription = $objUser.Description

$UserExpiration = $objUser.AccountExpirationDate

Func MyErrFunc()
;
EndFunc

Das Häschen benutzt Radar

Posted

Yeah, so if you just want the error to be ignored, this might work:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 

$objUser = ObjGet ("WinNT://MYDOMAIN/" & $Login & ",User" )

$UserLogin = $objUser.Name
$UserFullName = $objUser.FullName
$UserProfile = $objUser.Profile
$UserScript = $objUser.LoginScript
$UserDescription = $objUser.Description

$UserExpiration = $objUser.AccountExpirationDate

Func MyErrFunc()
;
EndFunc
Yeah, Thank You so much Squirrely1 and monoceres, this program is working for me!!! I don't need to use the error.

And sorry to awnser late ... I was just on holiday !!! :)

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
×
×
  • Create New...