![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-07 18:09 |
48,041 topics / 350,128 posts / today 3 new / 48,252 members |
| DOS批处理 & 脚本技术(批处理室) » [Perfect Solution] Regarding the Problem of Multi-threaded start && Command Connection |
| Printable Version 2,375 / 17 |
| Floor1 429499381 | Posted 2007-08-11 02:29 |
| 中级用户 Posts 202 Credits 452 | |
|
@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 ] |
|
| Floor2 429499381 | Posted 2007-08-11 06:00 |
| 中级用户 Posts 202 Credits 452 | |
|
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
|
|
| Floor3 Michael | Posted 2007-08-11 10:05 |
| 钻石会员 Posts 3,041 Credits 10,054 | |
| Floor4 429499381 | Posted 2007-08-11 16:17 |
| 中级用户 Posts 202 Credits 452 | |
|
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?? |
|
| Floor5 不得不爱 | Posted 2007-08-12 11:28 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
Just don't use the start command.
|
|
| Floor6 429499381 | Posted 2007-08-13 16:14 |
| 中级用户 Posts 202 Credits 452 | |
|
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 |
|
| Floor7 不得不爱 | Posted 2007-08-13 21:17 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
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 |
|
| Floor8 429499381 | Posted 2007-08-14 00:27 |
| 中级用户 Posts 202 Credits 452 | |
|
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!!! |
|
| Floor9 不得不爱 | Posted 2007-08-14 08:27 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
START cannot pass more than 2 commands in the new environment, but you can use the following method to solve your problem
|
|
| Floor10 ccwan | Posted 2007-08-14 09:31 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
What are the requirements of the LZ?
Like this? [ Last edited by ccwan on 2007-8-14 at 09:34 AM ] |
|
| Floor11 429499381 | Posted 2007-08-14 15:21 |
| 中级用户 Posts 202 Credits 452 | |
|
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!!! |
|
| Floor12 electronixtar | Posted 2007-08-14 15:48 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
| Floor13 429499381 | Posted 2007-08-14 20:01 |
| 中级用户 Posts 202 Credits 452 | |
|
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??? |
|
| Floor14 不得不爱 | Posted 2007-08-14 20:22 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
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.
|
|
| Floor15 ccwan | Posted 2007-08-15 08:06 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
What you have to love is very right
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |