Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Local Admin password change script gives and network error.

Hi,

Local Admin password change script gives and network error.
Can any one add the error check options for

no permission
Timedout
or any other issue it has to log that and proceed.

Regards
Sharath
Const ForAppending = 8
Const ForReading = 1
 
Set fso=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\pass_changed.txt")
Set objNetwork = CreateObject("Wscript.Network")
 
Set objFile=fso.OpenTextFile("C:\computers.txt", ForReading)
 
Do Until objFile.atEndofStream
     strComputer = objFile.ReadLine
    
Set objUser = GetObject("WinNT://" & strComputer & "/administrator")
 
intPasswordAge = objUser.PasswordAge
intPasswordAge = intPasswordAge * -1 
dtmChangeDate = DateAdd("s", intPasswordAge, Now)
 
objTextFile.WriteLine "Password for " & strComputer & " was last changed: " & dtmChangeDate
Loop

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Don
Don
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bsharath

ASKER