@REM ========================================================================================================================================================================================================= ========= @ ECHO OFFset zhl_file = task_1 $ .txtset zhl_temp_file = Temp1 $ .zhlset zhl_file2 = task_2 $ .txtset zhl_temp_file2 = Temp2 $ .zhlset temp_1 = lmj_zhl $ .txtset temp_2 = lmj_zhl2 $ .txtset zhl_1 = % 1SET ZHL_2 = 2: Beginif "% zhl_1%" == "" goto: help% zhl_1% == 0 @echo port number cannot be zero! && goto: ENDIF EXIST% zhl_file% ERASE% zhl_File% IF ERASE% zHL_TEMP_FILE% ERASE% zHL_TEMP_FILE% ECHO is processing network port ... netstat -ano | find ":">% zhl_file% 2> NulFor / f "eol = u Tokens = 1, 2, 3, 4, 5 * "%% a in (% zhl_file%) Do @echo %% a %% B $ %% C %% D #" "%% E" "# >>% ZHL_TEMP_FILE% 2> NulFor / f "EOL = T tokens = 1, 2, 3, 4 *" %% a in (% zhl_file%) Do @echo %% a %% b %% C * # "" %% D "" # >>% zhl_temp_file% 2> NULIF EXIST% zHL_FILE2% ERASE% zHL_FILE2% IF ERASE% zHL_TEMP_FILE2% ERASE% zHL_TEMP_FILE2% ECHO is reading process image ... Tasklist / fo csv>% zhl_file2% 2> Nulecho is initializing the image and port ... for / f "Skip = 2 tokens = 1, 2, 3, 4, 5 * Delims =," %% a in (% zhl_file2%) do @echo %% a , # %% B #, %% C, %% D, %% E >>% zHL_TEMP_FILE2% 2> Nulecho is looking for processes and port correspondence ... if exist% temp_1% ERASE% TEMP_1% TYPE% zHL_TEMP_FILE % | Find ":% zhl_1% $" >>% TEMP_1% 2> NulFor / f "tokens = 4, 5 *" %% x in (% TEMP_1%) Do @set zhl_2 = %% YIF "% zhl_2%" == "2" Echo No process use% zhl_1% port && goto: endtype% zhl_temp_file2% | Find "
% zhl_2% ">>% TEMP_2% 2> Nulfor / f" tokens = 1, 2 * delims =, "%% f in (% TEMP_2%) do @set zhl_3 = %% FeCho discovery process% zhl_3% use% zhl_1 % Port Rem if EXIST TEMP1.ZHL ERASE TEMP1.ZHLREM FOR / F "tokens = 2, 3 *" %% I in (1.txt) do @echo %% j * >> Temp1.zhlrem if EXIST TEMP2.ZHL ERASE Temp2.zhlrem for / f "tokens = 1, 2 * delims =:" %% j in (Temp1.zhl) do @echo %% K >> Temp2.zhlrem Echo% zhl_1% Rem type temp1.zhl | Find "% ZHL_1% * "/ ngoto: End: Helpecho WinXP / WIN2003 View which process is using echo.echo us:% 0 port: endRem ==================== ================ REM last cleaning work rad ============================ ======== Erase% zhl_File% 1> NUL 2> & 1Rase% zhl_file2% 1> NUL 2> & 1Rase% zhl_temp_file% 1> NUL 2> & 1Rase% zhl_temp_file2% 1> NUL 2> & 1Rase% TEMP_1% 1> NUL 2> & 1Rase% Temp_2% 1> NUL 2> & 1Set zhl_file = set zhl_temp_file = set zhl_file2 = set zhl_temp_file2 = set temp_1 = set zhl_1 = set zhl_2 =