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-08-01 12:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to use DOS to find an EXE file and then add it to the firewall rules to prohibit internet access View 2,249 Replies 1
Original Poster Posted 2021-03-30 11:20 ·  柬埔寨
新手上路
Credits 10
Posts 4
Joined 2021-03-29 21:21
5-year member
UID 184428
Gender Male
Status Offline
Environment:
Under Windows 10, when a program runs, it randomly generates a folder with a 12-character name in C:\Program Files\
Inside this folder, a 123.exe executable program will be generated
This 123.exe is what we need, but it has a serious bug when it connects to the Internet while running
So we need to add 123.exe to the firewall rules to prohibit it from connecting to the Internet

How to achieve this

PS: The randomly generated 12-character name folder is uncontrollable

Known firewall command
netsh advfirewall firewall add rule name="Rule" dir=in program="C:\Program Files\Randomly generated 12-character name folder\123.exe" action=block

[ Last edited by 1M1048576 on 2021-3-30 at 13:16 ]
Floor 2 Posted 2021-03-30 18:31 ·  柬埔寨
新手上路
Credits 10
Posts 4
Joined 2021-03-29 21:21
5-year member
UID 184428
Gender Male
Status Offline
I have an idea. First, use the dir command to find the 123.exe file. Then write the path of 123.exe to 1.txt. Then call the content in the 1.txt file to assign a value to a variable, and finally write the firewall rule. The commands are as follows:
cd c:\"program files"
dir /a -d /s /b 123.exe>1.txt
It has been tested that the complete path of 123.exe can be obtained, but I don't know how to do the next step of assignment...
Forum Jump: