|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『楼 主』:
[完美解决]关于多线程start && 命令连接的问题
使用 LLM 解释/回答一下
@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
上面的代码无法实现能PING 通的放入IP.txt 谁能告诉我为什么
Last edited by 429499381 on 2007-8-14 at 03:22 PM ]
@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 ]
|
|
2007-8-11 02:29 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
有谁知道如何让多线程并保留部分结果!!
如同是开20开窗口PING, 能PING通的放如1.txt
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
|
|
2007-8-11 06:00 |
|
|
Michael
钻石会员
       
积分 10046
发帖 3039
注册 2002-11-11
状态 离线
|
|
2007-8-11 10:05 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
但是用了 start /i 之后, 新开的窗口无法同时实现命令的连接!!
start /i tasklist & pause 其中pasue 无法传递在新环境下!!
有解吗??
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??
|
|
2007-8-11 16:17 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2007-8-12 11:28 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
不用START如何实现模拟多线程呢?? 给点提示!!! 我刚刚又试验了一下
下面的P处理能模拟多线程, 但无法退出!! 哎!!
set a=
:loop
set /a a+=1
cmd /c start echo %a% >>e:\%a%.txt
if "%a%"=="5" exit
goto :loop
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
|
|
2007-8-13 16:14 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
set a=
:loop
set /a a+=1
echo %a% >>e:\%a%.txt
if "%a%"=="5" exit
goto :loop
这样就可以了
@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
这也会正确,如果执行start /i /min ping -n 2 172.16.1.%c% && echo 172.16.1.%c% >>b:\ip.txt命令的话,系统会新开窗口执行ping -n 2 172.16.1.%c%同时在不等得到结果后就在本出口执行echo 172.16.1.%c% >>b:\ip.txt所以你的BAT会出错!
也就是说:start /i /min ping -n 2 172.16.1.%c% && echo 172.16.1.%c% >>b:\ip.txt
等效于:
start /i /min ping -n 2 172.16.1.%c%
echo 172.16.1.%c% >>b:\ip.txt
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
|

我的网络U盘 我的网络第2个U盘
论坛软件下载链接
灵雨飘零论坛
论坛新手必读,所有人的基本行为准则
刷QQ空间人气、留言的小软件 |
|
2007-8-13 21:17 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
我知道你说的, 我也实验过了!!
我是想知道如何模拟多线程 或者说有什么办法能让
START传递2个以上的命令在新环境下!!!
不知道我的表达够不够清楚!!! 有解吗? 给点提示!!!
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!!!
|
|
2007-8-14 00:27 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
START不能传递2个以上的命令在新环境下,不过可以用下面的方法来解决你的问题
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
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
|

我的网络U盘 我的网络第2个U盘
论坛软件下载链接
灵雨飘零论坛
论坛新手必读,所有人的基本行为准则
刷QQ空间人气、留言的小软件 |
|
2007-8-14 08:27 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
楼主的要求是什么?
这样?
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 ]
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 ]
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-8-14 09:31 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
10楼的满足了我的要求, 太谢谢你了, 我求了4天, 实验了6个小时都没结果,终于等到你了
我试过CMD /C START 为什么没想想试START CMD /C 呢??
对DOS还是不够娴熟!!!
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!!!
|
|
2007-8-14 15:21 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
多进程好不?
|

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'>" |
|
2007-8-14 15:48 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
唯一的好处是100%的CPU!! 本来是想写一个用WMIC查询有没有非法上机的批
处理
但是后来发现部分新的XP系统怎么也无法查询远程的进程名!! 总是拒绝访问!!
不解, 估计没开RPC远程过程调用吧!!
ccwan
请问为什么
set a=
:loop
set /a a+=1
start cmd /c &echo %a% >>%a%.txt
pause
if "%a%"=="5" exit
goto :loop
START CMD /C 后面加了 & 才能达到我的效果!! 这是为什么???
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???
|
|
2007-8-14 20:01 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2007-8-14 20:22 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
不得不爱说的很对
What you have to love is very right
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-8-15 08:06 |
|