#180697 - 2007-09-18 09:31 PM
Re: File not open for writing
[Re: Gargoyle]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Where is the PATH to the file?
This works for me
If Open(1,"C:\TEMP\SomeFile.txt",5) = 0
$wl = WriteLine(1,"A bunch of stuff"+@CRLF)
$wl = Close (1)
EndIf
|
|
Top
|
|
|
|
#180704 - 2007-09-18 10:19 PM
Re: File not open for writing
[Re: Gargoyle]
|
Gargoyle
MM club member
   
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Here is the full code
If Not @LOGONMODE
Break On
EndIf
$SO=SetOption("Explicit", "ON")
$SO=SetOption("NoMacrosInStrings", "ON")
$SO=SetOption("NoVarsInStrings", "ON")
$SO=SetOption("WrapAtEOL", "ON")
Dim $FH, $Date, $File, $Line, $Drive, $Element, $Input, $Type
Global $Array, $FH2
Use * "\\server\e$\audit" /user:"domainX\administrator" /password:"password"
$Drive = @RESULT
$File = DirPlus($Drive)
$FH = FreeFileHandle()
$FH2 = FreeFileHandle()
CLS
?"Search for username:"
Gets $input
If Open ($FH2,"C:\Scripthome\logs\Audit_"+$input+".txt",5) = 0
For Each $Element in $File
? $element
If Open ($FH,$element,2) = 0
$Line = ReadLine($FH)
While @ERROR = 0
$Array = Split ($Line," ")
If $Array[2] = "DomainX\"+$Input+":"
Select
Case $Array[3] = "Logon"
$Type = "On"
Case $Array[4] = "Logoff"
$Type = "Off"
Case 1
$Type = "Ignore"
EndSelect
Write($Type)
EndIf
$Line = ReadLine($FH)
Loop
EndIf
Close ($FH)
Next
Close($FH2)
Else
?@SERROR
EndIf
Use * /delete
Function Write($Type)
If $Type = "ON"
WriteLine($FH2,$Array[0]+" "+$Array[1]+" Successful network Logon: User Name "+$Array[2]+@CRLF+" "+"Workstation: "+$Array[12]+@CRLF)
EndIf
If $Type = "Off"
WriteLine($FH2,$Array[0]+" "+$Array[1]+" User Logoff"+@CRLF)
EndIf
EndFunction
_________________________
Today is the tomorrow you worried about yesterday.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|