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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT