Creating and Writing a Log File During Logon
Keywords: .LOG file logon
Question:
I compiled a Winbatch script that captures network printer object using con2prt.exe. I
have set up the winbatch .exe so that it runs from the user's logon script. In my
Winbatch script I would like to set up a function that
records what user logged on and executed the Winbatch .exe. Basically want to print
their
logon script name to a text file.
Answer:
Ummm the easy way....but it runs into
contention error on big networks:
logline=strcat(userid," ",scrpname)
gosub logit
...
exit
:logit ; contention prone but easy script
xxx=FileOpen("X:\stuff\script.log","APPEND")
FileWrite(xxx,logline)
FileClose(xxx)
return
Here's a more bulletproof script:
:logit ; bulletproof script
xxx=0
while xxx==0
...ErrorMode(@off)
...xxx=FileOpen("X:\stuff\script.log","APPEND")
...ErrorMode(@cancel)
...if xxx==0 then TimeDelay(1)
endwhile
FileWrite(xxx,logline)
FileClose(xxx)
return
WARNING: Using ErrorMode and very very very easily turn a 5 minute debugging
project into a 3 week debugging project. Never use it to protect an control (IF WHILE
FOR ETC) statement. Read ALL about it in the manual before ever consider using it.
Never suppress more than one line of cde at a time...
Article ID: W13519
Filename: Write LOG File During Logon.txt