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-07 19:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Perfect Solution] Regarding the Problem of Multi-threaded start && Command Connection View 2,377 Replies 17
Original Poster Posted 2007-08-11 02:29 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
@echo on

:loop

set /a c+=1

start /i /min ping -n 2 172.16.1.%c% && echo 172.16.1.%c% >>b:\ip.txt


if "%c%"=="20" exit

goto :loop


The above code fails to put the PING -successful IPs into ip.txt. Who can tell me why?

[ Last edited by 429499381 on 2007-8-14 at 03:22 PM ]
Floor 2 Posted 2007-08-11 06:00 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
Who knows how to make multi-threading and retain part of the results!! For example, opening 20 windows to PING, and putting the ones that PING successfully into 1.txt
Floor 3 Posted 2007-08-11 10:05 ·  中国 山东 济宁 兖州区 联通
钻石会员
★★★★★
Credits 10,054
Posts 3,041
Joined 2002-11-11 00:00
23-year member
UID 223
Gender Male
Status Offline
简单就是美
Floor 4 Posted 2007-08-11 16:17 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
But after using start /i, the newly opened window cannot realize the connection of commands at the same time!!

start /i tasklist & pause In which pasue cannot be passed in the new environment!!

Is there a solution??
Floor 5 Posted 2007-08-12 11:28 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 6 Posted 2007-08-13 16:14 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
How to achieve simulating multi-threads without using START?? Give some hints!!! I just tested again
The following P processing can simulate multi-threads, but cannot exit!! Hey!

set a=
:loop
set /a a+=1
cmd /c start echo %a% >>e:\%a%.txt
if "%a%"=="5" exit
goto :loop
Floor 7 Posted 2007-08-13 21:17 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
set a=
:loop
set /a a+=1
echo %a% >>e:\%a%.txt
if "%a%"=="5" exit
goto :loop
This is okay
@echo on

:loop
set /a c+=1
ping -n 2 172.16.1.%c% && echo 172.16.1.%c% >>b:\ip.txt
if "%c%"=="20" exit
goto :loop
This is also correct. If you execute the command start /i /min ping -n 2 172.16.1.%c% && echo 172.16.1.%c% >>b:\ip.txt, the system will open a new window to execute ping -n 2 172.16.1.%c% and then immediately execute echo 172.16.1.%c% >>b:\ip.txt without waiting for the result. So your BAT will be wrong!
That is to say: start /i /min ping -n 2 172.16.1.%c% && echo 172.16.1.%c% >>b:\ip.txt
is equivalent to:
start /i /min ping -n 2 172.16.1.%c%
echo 172.16.1.%c% >>b:\ip.txt
Floor 8 Posted 2007-08-14 00:27 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
I know what you're talking about, and I've also experimented with it!!

I want to know how to simulate multi-threading or what methods there are to make

START pass more than 2 commands in a new environment!!!

I don't know if my expression is clear enough!!! Is there a solution? Give some hints!!!
Floor 9 Posted 2007-08-14 08:27 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
START cannot pass more than 2 commands in the new environment, but you can use the following method to solve your problem
echo ping -n 2 172.16.1.%%1 ^&^& echo 172.16.1.%%1 ^>^>b:\ip.txt ^&exit>tmp.bat
:loop
set /a c+=1
start /i /min tmp.bat %c%
if "%c%"=="20" ping -n 5 127.1 &del tmp.bat&exit
goto :loop
Floor 10 Posted 2007-08-14 09:31 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
What are the requirements of the LZ?
Like this?

set a=
:loop
set /a a+=1
start cmd /c &echo %a% >>%a%.txt
pause
if "%a%"=="5" exit
goto :loop


[ Last edited by ccwan on 2007-8-14 at 09:34 AM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
429499381 +2 2007-08-14 15:19
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 11 Posted 2007-08-14 15:21 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
The requirement of floor 10 is met, thank you so much. I've been seeking it for 4 days and experimented for 6 hours without result, finally waiting for you.

I tried CMD /C START, why didn't I think of trying START CMD /C??

Still not proficient enough in DOS!!!
Floor 12 Posted 2007-08-14 15:48 ·  中国 四川 成都 联通
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 13 Posted 2007-08-14 20:01 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
The only advantage is 100% CPU!! Originally wanted to write a batch processing to query with WMIC whether there is illegal online, but later found that some new XP systems can never query the remote process name!! Always access denied!!

Puzzled, probably didn't enable RPC remote procedure call!!

ccwan
Why is that?
set a=
:loop
set /a a+=1
start cmd /c &echo %a% >>%a%.txt
pause
if "%a%"=="5" exit
goto :loop

After adding & after START CMD /C can achieve my effect!! Why is this???
Floor 14 Posted 2007-08-14 20:22 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
It's very simple. After adding &, the command echo %a% >>%a%.txt is executed in this window, and the newly opened window executes the next cmd /c command.
Floor 15 Posted 2007-08-15 08:06 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
What you have to love is very right
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Forum Jump: