China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 02:03
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to query whether a certain computer in the local area network is running a certain program (or port) View 2,211 Replies 4
Original Poster Posted 2006-04-25 01:24 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Here's the translation:

The situation is like this:
I and my colleagues have three computers, connected through a HUB, sharing a broadband account to access the internet through a proxy software. All three computers are on XP operating system, and both the server and client of the proxy software are installed. Whoever boots up first uses the account to log in. Others need to start the client to connect to the computer that has the server started. It's often one computer after another to try, to see who has started the server. If none have started, then one has to log in with the account oneself, which is very tedious.
Now I want to use a batch program, without third-party software, to automatically judge the running situation of the server. The key step is to query whether a certain program (such as server.exe) is running on a certain computer, or whether a certain port (such as 123) is open. How to program this?
Floor 2 Posted 2006-04-25 08:05 ·  中国 河南 郑州 电信
中级用户
★★
Credits 439
Posts 170
Joined 2006-01-09 20:29
20-year member
UID 48707
Status Offline
Scan the 18201 port of the machine 127.16.3.1. If "udp closed" is found to be closed, display A01 to C:\a.txt
Floor 3 Posted 2006-04-25 08:25 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Originally posted by a9319751 at 2006-4-25 08:05:
Example:
nmap -sU -p 18021 172.16.3.1 | find "udp closed" &if not errorlevel 1 @echo A01 >>C:\a.txt

Scan the 172.16.3.1 machine's port 18201, if "udp closed" is found to be closed...


After running in the cmd command line, it prompts that 'namp' is not an internal or external command, nor is it a runnable program or batch file. Is nmap not a cmd command on XP?
Floor 4 Posted 2006-04-25 14:06 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
It is difficult for cmd to achieve port-level applications without borrowing third-party tools. But what proxy software are you using? Doesn't the client automatically search and connect? It is suggested that you find one that can automatically search to use.

In addition, I don't know the working principle of the proxy software you are using, otherwise the purpose can be achieved pertinently. It is suspected that the key should be to change the gateway. Without its client, you can use netsh to get it done.

The following is a VBS script to judge whether the other party has enabled a certain port:


host=inputbox("Enter the host name or IP:")
port=inputbox("Port:")
Set socket=WScript.CreateObject("MSWinsock.Winsock","winsock_")
socket.Protocol=0
socket.RemotePort=port
socket.RemoteHost=host
socket.connect
for a=1 to 30
WScript.sleep 10
next
msgbox("Port "&socket.remoteport&" is closed!")
socket.close
WScript.quit
Sub winsock_connect()
msgbox("Port "&socket.remoteport&" is open!")
socket.close
WScript.quit
end sub


Save it as "Check Port.vbs" and then run it. The MSWinsock control needs to be registered.
Floor 5 Posted 2006-04-25 21:48 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Originally posted by 3742668 at 2006-4-25 14:06:
cmd cannot achieve port-level applications without the help of third-party tools. But what proxy software are you using? Doesn't the client automatically search and connect? It is suggested that you find a way to automatically search...


Using ccproxy and e-border driver combination
Forum Jump: