+ Post New Thread
Results 1 to 3 of 3
How do you do....it? Thread, automatic VNC to PC a user is logged onto in Technical; If you track your users logons to a database then you may find this script of some use as well ...
  1. #1
    ChrisP's Avatar
    Join Date
    Apr 2007
    Location
    norfolk
    Posts
    150
    Thank Post
    4
    Thanked 8 Times in 8 Posts
    Rep Power
    16

    automatic VNC to PC a user is logged onto

    If you track your users logons to a database then you may find this script of some use as well as an exaple of messy coding to give you a chuckle. We have three domains here and this is my solution to quickly VNC into a user to support them without having to track down what PC they are logged into.

    You will need to make some small ammendments to suit your environment but it should be easy enough to understand.


    Code:
    	Set WshShell 		= 		Wscript.CreateObject("WScript.Shell")
    	SQLstring		=		"SELECT * FROM [logons]"	
    	FilterUser		= 		InputBox("Logon name ?", "", "")
     	if FilterUser 		<> ""		then SQLstring = SQLstring & " where [user] LIKE '"&FilterUser&"'"
     	SQLstring 		= 		SQLstring &  " ORDER BY [id] Desc"
    	Set oDB 		= 		CreateObject("ADODB.Connection")
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    	oDB.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=\\99.99.99.99\logging$\database\logon_watch.mdb"
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    	Set oRS 		= 		oDB.Execute(SQLstring)
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    if 	oRS.EOF then
    	Wscript.echo(vbcrlf &vbcrlf &"Nothing found in the database"&vbcrlf &vbcrlf &"Sorry !!"&vbcrlf &vbcrlf )
    	Wscript.quit
    end if
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    	oUSR			=		(oRS.Fields.Item("user").Value)
    	oPC			=		(oRS.Fields.Item("pc").Value)
    	oDATE			=		split((oRS.Fields.Item("serverdate").Value),"/")
    	Set oDB			= 		Nothing
    	todayDate		=		split(date(),"/")
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    if 	(todayDate(0) = oDate(0)) and (todayDate(1) = oDate(1)) or (todayDate(0) = oDate(1)) and (todayDate(1) = oDate(0)) then
    	WshShell.Run ("z:\!!-exe\vnc.exe " &oPC&":5252")
    else
    	Wscript.echo(oPC & "-not logged on today")
    end if

  2. #2

    Join Date
    Jun 2007
    Posts
    90
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: automatic VNC to PC a user is logged onto

    What do I have to do with it. This would be useful. Would it work with RM CC3, I think that knows whos logged on where.

    If we dont track it, how can I do that?

    Thanks :-)

  3. #3
    sahmeepee's Avatar
    Join Date
    Oct 2005
    Location
    Greater Manchester
    Posts
    795
    Thank Post
    20
    Thanked 70 Times in 42 Posts
    Rep Power
    34

    Re: automatic VNC to PC a user is logged onto

    Nice post Chris.

    I'm not sure if it speeds the query up to do "SELECT TOP 1 * FROM [logons]" on line 2. Possibly not significantly.

    Another tweak would be to check if anyone else has logged on at that PC since FilterUser (meaning FilterUser can't still be logged on). You could just run a 2nd query to find the most recent logon at the PC and then compare names.

    It might also be nice to have a box pop up to say "user logged on at xx:xx today, connect?". If they logged on at 09:15 and it's lunchtime there's not much point connecting.

    I'm looking into making our login database track logoff events as well, if only to get an idea of how many PCs are being shut down gracefully. It might also come in handy for scripts like these.

SHARE:
+ Post New Thread

Similar Threads

  1. Automatic PC Shutdown on an evening
    By lindsayecroft in forum MIS Systems
    Replies: 11
    Last Post: 11th March 2008, 02:21 PM
  2. SIMS and Automatic Updates
    By techyphil in forum Windows
    Replies: 9
    Last Post: 14th June 2007, 07:40 PM
  3. Replies: 5
    Last Post: 21st February 2007, 04:40 PM
  4. Nova-T Automatic Backups
    By sidewinder in forum MIS Systems
    Replies: 0
    Last Post: 3rd November 2006, 01:05 PM
  5. Automatic site backup
    By ajbritton in forum Web Development
    Replies: 1
    Last Post: 10th October 2006, 09:03 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •