Tag Archives: Remote Desktop Connection

Get current remote connections with LiveCode on MS Windows XP/Vista/7

This is a script to check the remote desktop connections to your computer. Syntax:

rdConnection([false]|true|”User”)

where User is the name of a user with an account on that particular computer (or server).

Paremeters:
false: returns true if connections have been established, false of not
true: returns the names of the currently logged in users
user (in quotes): returns true if that particular user is logged in, false otherwise

function rdConnection theName
   if the platform is not “Win32” then return empty
   set the hideConsoleWindows to true
   put shell(“qwinsta”) into myConnections
   filter myConnections with “*Active*”
   if theName is empty or theName is false then
      repeat for each line myLine in myConnections
         if word 4 of myLine is “Active” then
            put myLine & cr after myNewList
         end if
      end repeat
      delete last char of myNewList
      return (myNewList is not empty)
   else if theName is true then
      repeat for each line myLine in myConnections
         if word 4 of myLine is “Active” then
            put word 2 of myLine & cr after myNewList
         end if
      end repeat
      return myNewList
   else // theName is not empty
      if word 2 of myLine is theName then
         put myLine & cr after myNewList
      end if
      delete last char of myNewList
      return (myNewList is empty)
   end if
end rdConnection