当前位置:编程学习 > VB >>

如何判断已经成功登陆一台服务器的终端 3389?

怎么通过编程来判断已经成功登陆了我的服务器 终端不需要在登陆了?

从窗口上入手的话没判断登陆框的句柄

从网络上的话

可以从是不是连接到 远程 12.12.12.12 的 3389端口来判断 或者是否交互数据 

我只想到这么多

但是如果从端口上判断的话 应该怎么写呢?

如果从netstat -an>>c:\login.txt

之后分析文本 

假设服务器没有成功登陆 那里也会显示连接了3389 所以这个不准确


--------------------编程问答-------------------- Query user

Displays information about user sessions on a terminal server.

Syntax
query user [{UserName|SessionName|SessionID}] [/server:ServerName]

Top of page
Parameters
UserName : Specifies the logon name of the user you want to query. 

SessionName : Specifies the name of the session you want to query. 

SessionID : Specifies the ID of the session you want to query. 

/server:ServerName : Specifies the terminal server you want to query. Otherwise, the current terminal server is used. 

/? : Displays help at the command prompt. 

Top of page
Remarks
• You can use this command to find out if a specific user is logged on to a specific terminal server. Query user returns the following information: 

• The name of the user 
 
• The name of the session on the terminal server 
 
• The session ID 
 
• The state of the session (active or disconnected) 
 
• The idle time (the number of minutes since the last keystroke or mouse movement at the session) 
 
• The date and time the user logged on 
 
 
• To use query user, you must have Full Control permission or Query Information special access permission. 
 
• If you use query user without specifying a user name, session name, or session ID, a list of all users who are logged on to the server is returned. Alternatively, you can also use query session to display a list of all sessions on a server. 
 
• When query user returns information, a less than (>) symbol is displayed before the current session. 
 
• The /server parameter is required only if you use query user from a remote server. 
 

Top of page
Examples
To display information about all users logged on the system, type:

query user

To display information about the user USER1 on server SERVER1, type:

query user USER1 /server:SERVER1

Top of page
Formatting legend
Format Meaning 
Italic
 Information that the user must supply
 
Bold
 Elements that the user must type exactly as shown
 
Ellipsis (...)
 Parameter that can be repeated several times in a command line
 
Between brackets ([])
 Optional items
 
Between braces ({}); choices separated by pipe (|). Example: {even|odd}
 Set of choices from which the user must choose only one
 
Courier font
 Code or program output
 
--------------------编程问答-------------------- Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\Administrator>query
Invalid parameter(s)
QUERY { PROCESS | SESSION | TERMSERVER | USER }

C:\Documents and Settings\Administrator>query user
 USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
 administrator         console             0  Active          .  2010-8-13 13:20

>administrator         rdp-tcp#2           1  Active          .  2010-8-24 18:22


C:\Documents and Settings\Administrator> --------------------编程问答-------------------- 不知道  --------------------编程问答-------------------- 列位 我说的是在本地环境下去判断自己的电脑成功登陆了 其他服务器的终端
补充:VB ,  网络编程
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,