Jump to content

Problem with .AccountExpirationDate property


L'egyptien
 Share

Recommended Posts

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
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 !!! :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...