@echo offif "%1" = = "h" goto begin Mshta Vbscript:createobject ("Wscript.Shell"). Run ("%~nx0 h", 0) (window.close) && ; Exit:begin set Port=3389set checkinterval=2set prev= "": Loopset curr=for/f "delims="%%i in (' Netstat-n-p TCP ^|find ^ ":%port%^" ') do (set curr=%%i) if not "%curr%" = = "%prev%" (set prev=%curr% date/t >>rdplog.txt time/t >> ; RDPlog.txt echo%curr% >>rdplog.txt) ping-n%checkinterval% 127.1>nul Goto:loop
The Remote Desktop Services port (ports) is 3389;
The current polling frequency (Checkinterval) is set to 2 seconds;
After the script runs in the background, the console window is not visible, and when the detection service port connection status changes, the time and the other IP are recorded in the RDPlog.txt.
The script is set to boot from the start on the line.
This article is from the "zl1030 Records" blog, so be sure to keep this source http://zl1030.blog.51cto.com/274507/1925247
Logging the Windows Remote Desktop User logon log through a CMD script