|
-
January 21st, 2009, 11:41 AM
#1
Detect remote desktop session on remote computer
I would like to have one computer look at another computer and determine if there is a remote desktop session active.
Example: want computer B to look at computer A and determine if there is no remote desktop session or if some other computer is remoted in.
Is this possible either through WMI, port scanning, reading the remote registry, etc?
The nice thing is we use a generic administrator account for all computers, so security is not an issue.
-
January 21st, 2009, 12:20 PM
#2
Re: Detect remote desktop session on remote computer
i checked the status of my listening ports in my system before activating remote desktop using this command:
netstat -an |find /i "listening"
status before activating remote desktop:
Code:
C:\Documents and Settings\touraj58>netstat -an |find /i "listening
TCP 0.0.0.0:25 0.0.0.0:0 LISTENING
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
TCP 0.0.0.0:5051 0.0.0.0:0 LISTENING
TCP 0.0.0.0:5101 0.0.0.0:0 LISTENING
TCP 127.0.0.1:1061 0.0.0.0:0 LISTENING
TCP 195.146.33.146:139 0.0.0.0:0 LISTENING
and status after activating remote desktop:
Code:
C:\Documents and Settings\touraj58>netstat -an |find /i "listening
TCP 0.0.0.0:25 0.0.0.0:0 LISTENING
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING
TCP 0.0.0.0:5051 0.0.0.0:0 LISTENING
TCP 0.0.0.0:5101 0.0.0.0:0 LISTENING
TCP 127.0.0.1:1061 0.0.0.0:0 LISTENING
TCP 195.146.33.146:139 0.0.0.0:0 LISTENING
so the guilty is port 3389...(to be sure several times i turned it on and off).
it is only enough to check that port 3389 is in listening mode in destination PC.
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
January 22nd, 2009, 05:30 PM
#3
Re: Detect remote desktop session on remote computer
now that we know the port is 3389
we can use a simple code like this to check if the remote desktop is ON or OFF:
Code:
IPAddress IPtoScan = IPAddress.Parse("192.168.220.55"); // example IP address
try
{
TcpClient Scanner = new TcpClient();
Scanner.Connect(IPtoScan, 3389);
MessageBox.Show("Remote desktop is ON");
}
catch
{
MessageBox.Show("Remote desktop is OFF");
}
don't forget to add these usings to your code:
using System.Net;
using System.Net.Sockets;
Last edited by toraj58; January 22nd, 2009 at 05:34 PM.
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
January 23rd, 2009, 07:22 AM
#4
Re: Detect remote desktop session on remote computer
-
January 23rd, 2009, 10:07 AM
#5
Re: Detect remote desktop session on remote computer
your welcome
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
March 1st, 2009, 05:12 AM
#6
Re: Detect remote desktop session on remote computer
hi,
can you send all source code?
thanks.
-
March 2nd, 2009, 02:47 AM
#7
Re: Detect remote desktop session on remote computer
here is all source code example:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace port_scanner
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
IPAddress IPtoScan = IPAddress.Parse("192.168.0.11");
try
{
TcpClient Scanner = new TcpClient();
Scanner.Connect(IPtoScan, 3389);
MessageBox.Show("Remote desktop is ON");
}
catch
{
MessageBox.Show("Remote desktop is OFF");
}
}
}
}
do not forget to add a button to the form.
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|