BrainDump
  Home arrow BrainDump arrow Page 3 - Logging Windows 2003 Terminal Server Conne...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Logging Windows 2003 Terminal Server Connections
By: Luke Niland
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2007-06-19

    Table of Contents:
  • Logging Windows 2003 Terminal Server Connections
  • Creating the Batch File and Why it’s Used
  • Writing the Script
  • Running the Batch File

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Logging Windows 2003 Terminal Server Connections - Writing the Script


    (Page 3 of 4 )

    Now that we have the batch file that will provide us with the information, we can start to write our VB script. Again open up your preferred text editor, and type the following code. We will write the script a section at a time and then explain the code.

    'Create the objects

    Set objwsh = WScript.CreateObject("WScript.Shell")

    Set objFSO= CreateObject("Scripting.FileSystemObject")

     

    'set the initial vars

    CONST ForReading = 1

    CONST ForWriting = 2

     

    'get the computer name from the reg

    strServerName = objwsh.RegRead("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControl
    ComputerNameActiveComputerNameComputerName")

     

    'set the current date in a format SQL will understand

    strSQLDate = DatePart("yyyy", Now()) & "-" & DatePart("m", Now()) & "-" & DatePart("d", Now()) & " " & DatePart("h", Now()) & ":"  & DatePart("n", Now()) & ":" & DatePart("s", Now()) 

     

    'set the initial line counter

    intLineCnt = 0

     

    'run the user query batch file to get the latest user info.

    objwsh.Run "c:GetTSUserInfo.bat",1,true   

    The couple of lines simply create two objects: objwsh is the shell object, and objFSO is the file system object.

    Then we set two constants for when we read and write to our text files.

    The next part uses the Shell object we created, gets the current computer name out of the registry and stores it in a variable to use later.

    Then we assign the variable strSQLDate to be the current date and time, in a format that we can use successfully in the SQL query, which we will use to update our table. The next line sets the initial line count to zero.

    More BrainDump Articles
    More By Luke Niland


       · Hi,Just a bit of info as to how I used this technique in my organization. We...
     

    BRAINDUMP ARTICLES

    - Internet Explorer 8 Review
    - Nilpo`s Top Windows Add-Ons
    - Beginning Silverlight 2.0 Development using ...
    - Fixing Vista`s Troubles
    - Preparing Windows Images for Mass Deployment
    - The Trouble With Vista
    - Slipstreamed and Unattended Windows Installa...
    - Microsoft Office SharePoint Server
    - Microsoft Office SharePoint Designer
    - Microsoft Windows SharePoint Services 3.0
    - Microsoft Live Mesh Overview
    - XAML Brushes and Silverlight
    - Silverlight and XAML Basics
    - Immortal XP
    - XAML Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT