Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Login Script logging

Reply
 
Old 10-22-2009   #1 (permalink)
Carl Hilton


 
 

Login Script logging

I have a logon script that writes values to a CSV file. I want to
create some method to minimize the number of missed entries because
two people are trying to write to the same file at the same time... I
was using

Set objTextFileLog = objFSO.OpenTextFile(strSharedFolder & "Logon-
WMI.txt", 8, True)

objTextFileLog.WriteLine _
Chr(34) & strCurDate & Chr(34) & Chr(9) _
& Chr(34) & strCurTime & Chr(34) & Chr(9) _
& Chr(34) & strUser & Chr(34) & Chr(9) _
& Chr(34) & strComputer & Chr(34) & Chr(9) _
& Chr(34) & OSName & Chr(34) & Chr(9) _
& Chr(34) & OSVersion & Chr(34) & Chr(9) _
& Chr(34) & OSServicePack & Chr(34) & Chr(9) _
& Chr(34) & SystemManufacturer & Chr(34) & Chr(9) _
& Chr(34) & SystemModel & Chr(34) & Chr(9) _
& Chr(34) & SystemType & Chr(34) & Chr(9) _
& Chr(34) & strDellAsset & Chr(34) & Chr(9) _
& Chr(34) & TimeZone & Chr(34) & Chr(9) _
& Chr(34) & TotalPhysicalMemory & Chr(34) & Chr(9) _
& Chr(34) & BiosVersion & Chr(34) & Chr(9) _
& Chr(34) & strValidMACAddress & Chr(34) & Chr(9) _
& Chr(34) & strIPAddress & Chr(34) & Chr(9) _
& Chr(34) & strAVVersion & Chr(34) & Chr(9) _
& Chr(34) & strAVDatVersion & Chr(34) & Chr(9) _
& Chr(34) & strcapacity & Chr(34) & Chr(9) _
& Chr(34) & strfree & Chr(34) & Chr(9) _
& Chr(34) & strDC & Chr(34) & Chr(9) _
& Chr(34) & "V: " & strWordVer & Chr(34) & Chr(9) _
& Chr(34) & strDNSDomain & Chr(34)

objTextFileLog.Close

Which is working fine, but want to ensure no one is getting left
out... I only have 250 users, so the odds that two folks would access
the same file are small, (unlike a large 1000+ organization) but just
looking for a "better" solution.

I had though of using a DO WHILE loop and checking err.number <>0 but
don't know of that should be on the WriteLine command or the
OpenTextFile command. Or maybe do something different.

My System SpecsSystem Spec
Old 10-22-2009   #2 (permalink)
John J. Jobst


 
 

Re: Login Script logging

A DO WHILE on opening the file exclusively would work best, with provisions
to time out in case the other process hangs some how and leaves the file
open.

"Carl Hilton" <carlvh@newsgroup> wrote in message
news:9951bfa1-9342-4d1f-bd2b-4047e92b9d27@newsgroup
Quote:

>I have a logon script that writes values to a CSV file. I want to
> create some method to minimize the number of missed entries because
> two people are trying to write to the same file at the same time... I
> was using
>
> Set objTextFileLog = objFSO.OpenTextFile(strSharedFolder & "Logon-
> WMI.txt", 8, True)
>
> objTextFileLog.WriteLine _
> Chr(34) & strCurDate & Chr(34) & Chr(9) _
> & Chr(34) & strCurTime & Chr(34) & Chr(9) _
> & Chr(34) & strUser & Chr(34) & Chr(9) _
> & Chr(34) & strComputer & Chr(34) & Chr(9) _
> & Chr(34) & OSName & Chr(34) & Chr(9) _
> & Chr(34) & OSVersion & Chr(34) & Chr(9) _
> & Chr(34) & OSServicePack & Chr(34) & Chr(9) _
> & Chr(34) & SystemManufacturer & Chr(34) & Chr(9) _
> & Chr(34) & SystemModel & Chr(34) & Chr(9) _
> & Chr(34) & SystemType & Chr(34) & Chr(9) _
> & Chr(34) & strDellAsset & Chr(34) & Chr(9) _
> & Chr(34) & TimeZone & Chr(34) & Chr(9) _
> & Chr(34) & TotalPhysicalMemory & Chr(34) & Chr(9) _
> & Chr(34) & BiosVersion & Chr(34) & Chr(9) _
> & Chr(34) & strValidMACAddress & Chr(34) & Chr(9) _
> & Chr(34) & strIPAddress & Chr(34) & Chr(9) _
> & Chr(34) & strAVVersion & Chr(34) & Chr(9) _
> & Chr(34) & strAVDatVersion & Chr(34) & Chr(9) _
> & Chr(34) & strcapacity & Chr(34) & Chr(9) _
> & Chr(34) & strfree & Chr(34) & Chr(9) _
> & Chr(34) & strDC & Chr(34) & Chr(9) _
> & Chr(34) & "V: " & strWordVer & Chr(34) & Chr(9) _
> & Chr(34) & strDNSDomain & Chr(34)
>
> objTextFileLog.Close
>
> Which is working fine, but want to ensure no one is getting left
> out... I only have 250 users, so the odds that two folks would access
> the same file are small, (unlike a large 1000+ organization) but just
> looking for a "better" solution.
>
> I had though of using a DO WHILE loop and checking err.number <>0 but
> don't know of that should be on the WriteLine command or the
> OpenTextFile command. Or maybe do something different.

My System SpecsSystem Spec
Old 10-22-2009   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: Login Script logging


"Carl Hilton" <carlvh@newsgroup> wrote in message
news:9951bfa1-9342-4d1f-bd2b-4047e92b9d27@newsgroup
Quote:

>I have a logon script that writes values to a CSV file. I want to
> create some method to minimize the number of missed entries because
> two people are trying to write to the same file at the same time... I
> was using
>
> Set objTextFileLog = objFSO.OpenTextFile(strSharedFolder & "Logon-
> WMI.txt", 8, True)
>
> objTextFileLog.WriteLine _
> Chr(34) & strCurDate & Chr(34) & Chr(9) _
> & Chr(34) & strCurTime & Chr(34) & Chr(9) _
> & Chr(34) & strUser & Chr(34) & Chr(9) _
> & Chr(34) & strComputer & Chr(34) & Chr(9) _
> & Chr(34) & OSName & Chr(34) & Chr(9) _
> & Chr(34) & OSVersion & Chr(34) & Chr(9) _
> & Chr(34) & OSServicePack & Chr(34) & Chr(9) _
> & Chr(34) & SystemManufacturer & Chr(34) & Chr(9) _
> & Chr(34) & SystemModel & Chr(34) & Chr(9) _
> & Chr(34) & SystemType & Chr(34) & Chr(9) _
> & Chr(34) & strDellAsset & Chr(34) & Chr(9) _
> & Chr(34) & TimeZone & Chr(34) & Chr(9) _
> & Chr(34) & TotalPhysicalMemory & Chr(34) & Chr(9) _
> & Chr(34) & BiosVersion & Chr(34) & Chr(9) _
> & Chr(34) & strValidMACAddress & Chr(34) & Chr(9) _
> & Chr(34) & strIPAddress & Chr(34) & Chr(9) _
> & Chr(34) & strAVVersion & Chr(34) & Chr(9) _
> & Chr(34) & strAVDatVersion & Chr(34) & Chr(9) _
> & Chr(34) & strcapacity & Chr(34) & Chr(9) _
> & Chr(34) & strfree & Chr(34) & Chr(9) _
> & Chr(34) & strDC & Chr(34) & Chr(9) _
> & Chr(34) & "V: " & strWordVer & Chr(34) & Chr(9) _
> & Chr(34) & strDNSDomain & Chr(34)
>
> objTextFileLog.Close
>
> Which is working fine, but want to ensure no one is getting left
> out... I only have 250 users, so the odds that two folks would access
> the same file are small, (unlike a large 1000+ organization) but just
> looking for a "better" solution.
>
> I had though of using a DO WHILE loop and checking err.number <>0 but
> don't know of that should be on the WriteLine command or the
> OpenTextFile command. Or maybe do something different.
Here is an example logon script that logs to a shared file. I use a loop
where I trap the possible error and make three attempts to write:

http://www.rlmueller.net/Logon5.htm

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Logging Success or Failure of a script VB Script
Netware login takes multiple tries before logging in. Network & Sharing
Login script VB Script
Login script Vista security
Login Script Problems Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46