General discussion

Locked

Windows Scripting Error Handling

By Martin Powell ·
I'm writing a script that will create users in Active Directory. The script runs OK and does what I want it to, but I'm trying to report any errors to a text file.

See Sample extract below, using arrInput variables:

Set objUser = objOU.Create("User", "cn=" & arrInput(1))
objUser.Put "sAMAccountName", arrInput(1)
objUser.Put "userPrincipalName", arrInput(1) & "@hcctest.gov.uk"
objUser.SetInfo

If Err.Number = 0 Then
f.Write arrInput(4) & " - " & Err.Number & " - " & Err.Description f.WriteBlankLines(1)
Err.Clear
f.close
Else
'wscript.echo arrInput(4) & " Created successfully"
f.Write arrInput(4) & " Created successfully"
f.WriteBlankLines(1)
f.Close
End If

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Windows Scripting Error Handling

by andybonner In reply to Windows Scripting Error H ...

Dim fso
Set fso=WScript.CreateObject("Scripting.FileSystemObject")
Set outfile=fso.CreateTextFile("F:\" & "myFile.txt")
outfile.writeline("'Whatever you want to write'")
outfile.close

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums