从远程登录用户获取计算机名称。 [英] Get computer name from remote logged user.

查看:435
本文介绍了从远程登录用户获取计算机名称。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时工作,很多人都在远程连接同一台用户的同一台电脑。



我想得到电脑的名字用户做了遥控器。



我想制作一个小程序来检查登录用户远程登录到计算机的哪台计算机。 c#或java脚本或vbscript。



另外,如果可能的话,检查登录用户的计算机名称并安装一些程序。

I意思是如果我检查已安装的程序B,我会得到安装它的登录用户的计算机名称。



谢谢,Imbaro。

Hi, im working in a compant that alot of people are remote connecting the same computer with the same user.

I want to get the name of the computer that the user did the remote from.

I want to make a small program to check which computer the logged on user remoted to the computer and It doesn't matter if c# or java script or vbscript.

Also, if possible, to check the computer name of user logged and installed some program.
I mean that if i check installed program B, i get the computer name of the logged in user that installed it.

Thanks, Imbaro.

推荐答案

如果没有关于您的应用程序的任何信息,我只能假设您要运行外部程序并查找任何连接的计算机的DNS名称。我将完成我将采取的步骤:



首先,我将使用命令行参数-a启动进程netstat。重定向输出以便您可以阅读:



Without having any information on your application I can only assume that you want to run an external program and find the DNS names of any connected computers. I'll go through the steps I would take:

First, I'd start the process "netstat" with the command line arguments "-a". Redirect the output so you can read it:

Process netStat = new Process();
netStat.StartInfo.UseShellExecute = true;
netStat.StartInfo.CreateNoWindow = true;
netStat.StartInfo.FileName = "netstat";
netStat.StartInfo.Arguments ="-a";
netStat.StartInfo.RedirectStandardOutput = true;

netStat.Start();   //Can take several seconds to execute, good use for BackgroundWorker

string output = netStat.StandardOutput.ReadToEnd();





现在你有了连接到计算机的所有内容的数据(输入和输出)。您可以在控制台窗口中运行netstat命令以查看输出。然后,您可以按行分割以获取每个条目,然后通过制表符再次拆分以获取每个列。您感兴趣的是第三列,其中包含computername:port或ipaddress:port,如果无法确定名称。



Now you have the data for everything connected to the computer (in and out). You can run the netstat command in a console window to see the output. You would then split this by lines to get each entry, and then split it again by tabs to get each column. You are interested in the third column, which has the computername:port or ipaddress:port if the name can't be determined.


这篇关于从远程登录用户获取计算机名称。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆