Subscribe to Windows IT Pro
December 16, 2009 12:00 AM

Making a Logon Script Expire

Windows IT Pro
InstantDoc ID #103170
Rating: (1)

Listing 1: An Expiring Logon Audit of Printers

If Date() < #2010-02-01# Then

 

   'using pn prefix for variables to limit name collisions

   ' Begin printer audit code

   Dim pnNet, pnPrinters, pnSd, pnSh, pnCount

   Dim pnUser, pnComputer, pnLogonServer, pnMsg

   Set pnNet = CreateObject("WScript.Network")

   set pnPrinters = pnNet.EnumPrinterConnections()

   set pnSD = CreateObject("Scripting.Dictionary")

   set pnSh = CreateObject("WScript.Shell")

   pnUser = pnNet.UserName

   pnComputer = pnNet.ComputerName

   pnLogonServer = pnSh.ExpandEnvironmentStrings("%LOGONSERVER%")

   pnSd( "user " & pnUser & " logging on from " & pnComputer _

       & " has these printers:") = ""

   for pnCount = 0 to pnPrinters.length -1 Step 2

       pnSD(pnPrinters(pnCount) _

           & " = " & pnPrinters(pnCount + 1)) = ""

   next

   pnMsg = Join(pnSd.Keys, vbCrLf)

   pnSh.LogEvent 4, pnMsg, pnLogonServer

   ' end printer audit code

 

End If

 

Related Content:

ARTICLE TOOLS

Comments
  • Ed
    2 years ago
    Jan 05, 2010

    I've always used the yyyy-MM-dd format in everything. It's understood [And it's easier for sorting purposes.] When you get something like 1-5-2010 and you are in July, is that January 5th or May 1st?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.