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



LinkBack URL
About LinkBacks
Reply With Quote

