|  | 
 
| flyhighxu 初级用户
 
   
 
 
 
 积分 32
 发帖 11
 注册 2008-3-8
 状态 离线
 | 
| 『楼 主』:
 请教调用文件时,call和start的区别?
 
使用 LLM 解释/回答一下 
 
 
举例:有两个批处理文件,a.bat和b.bat
 在a.bat里使用call b.bat或者start b.bat,实现在运行a.bat时调用运行b.bat。
 请问在这里,使用call和start有什么区别呢?谢谢
 
Example:There are two batch files, a.bat and b.bat.
 Using call b.bat or start b.bat in a.bat to realize calling and running b.bat when running a.bat.
 Then, what is the difference between using call and start here? Thanks
 
 
 
 |  | 
|  2008-3-30 15:14 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
| 『第 2 楼』:
 不知对你有帮助不:
 
使用 LLM 解释/回答一下 
 
 
call一般是调用批处理本身的里面的命令,如for /l %%i in (1,1,3) do call :run
 ...........................................
 :run
 start b.bat
 goto :eof
 ...........................................
 就是调用三次b.bat
 
 而start只能用来调用批处理的外部命令,如
 for /l %%i in (1,1,3) do start b.bat
 也是调用三次b.bat
 
 又如
 set /a str=%random%%%%10
 if %str% geq 5 start b.bat
 ...........................................
 只要条件满足(%str%>=5)就调用b.bat
 
 Last edited by zw19750516 on 2008-3-30 at 03:26 PM ]
 
call generally calls commands within the batch script itself, such as:
 for /l %%i in (1,1,3) do call :run
 
 ...........................................
 
 :run
 start b.bat
 goto :eof
 
 ...........................................
 
 That is to call b.bat three times.
 
 And start can only be used to call external commands of the batch script, such as:
 
 for /l %%i in (1,1,3) do start b.bat
 
 Also calls b.bat three times.
 
 For example:
 
 set /a str=%random%%%10
 if %str% geq 5 start b.bat
 
 ...........................................
 
 As long as the condition is met (%str% >= 5), b.bat is called.
 
 Last edited by zw19750516 on 2008-3-30 at 03:26 PM ]
 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-3-30 15:21 |  | 
|  | 
 
| knoppix7 银牌会员
 
      
 
 
 
 积分 1287
 发帖 634
 注册 2007-5-2
 来自 cmd.exe
 状态 离线
 | 
| 『第 3 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
call 继承当前的变量,变量可传递到父bat 
call 继承当前的变量,变量可传递到父bat
 call Inherits the current variables, and variables can be passed to the parent bat
 
 
 
 |  | 
|  2008-3-30 18:31 |  | 
|  | 
 
| Shinaterry 初级用户
 
   
 
 
 
 积分 97
 发帖 51
 注册 2008-3-19
 状态 离线
 |  | 
|  2008-3-30 19:08 |  | 
|  | 
 
| knoppix7 银牌会员
 
      
 
 
 
 积分 1287
 发帖 634
 注册 2007-5-2
 来自 cmd.exe
 状态 离线
 | 
| 『第 5 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
start 一般是用来同时启动的.不过2个cmd直接互相传递变量很难。所以很少用..
 
 不过对于debug command这样的可以以文本文件作为输入的话。start是很有用的.
 start 一个debug <r:\debug.txt
 然后父BAT直接echo a 100>>r:\debug.txt 之类的.比反复启动debug方便很多
 
start is generally used for starting simultaneously.However, it's very difficult to pass variables between 2 cmd directly. So it's rarely used..
 
 But for something like debug command that can take a text file as input, start is very useful.
 start a debug <r:\debug.txt
 Then the parent BAT can directly echo a 100>>r:\debug.txt and so on. It's much more convenient than starting debug repeatedly
 
 
 
 |  | 
|  2008-3-30 21:17 |  | 
|  | 
 
| flyhighxu 初级用户
 
   
 
 
 
 积分 32
 发帖 11
 注册 2008-3-8
 状态 离线
 | 
| 『第 6 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Originally posted by zw19750516 at 2008-3-30 03:21 PM:call一般是调用批处理本身的里面的命令,如
 for /l %%i in (1,1,3) do call :run
 ...........................................
 :run
 start b.bat
 goto :eof
 ............ ...
 
谢谢,可是call除了调用批处理本身的命令,也可以调用外部命令,是不是可以说 
在调用外部命令上,call和start都可以,功能重叠了? 
Originally posted by zw19750516 at 2008-3-30 03:21 PM:call is generally used to call commands within the batch itself, such as
 for /l %%i in (1,1,3) do call :run
 ...........................................
 :run
 start b.bat
 goto :eof
 ............ ...
 
Thanks, but besides calling commands within the batch itself, call can also call external commands. Does that mean that in terms of calling external commands, both call and start can be used, and their functions overlap? 
 
 
 |  | 
|  2008-3-31 00:00 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
| 『第 7 楼』:
 再啰嗦两句了:
 
使用 LLM 解释/回答一下 
 
 
Originally posted by flyhighxu at 2008-3-31 00:00:
 
 谢谢,可是call除了调用批处理本身的命令,也可以调用外部命令,是不是可以说
 在调用外部命令上,call和start都可以,功能重叠了?
 
 call和start都可以调用批处理的外部命令,但还是存在着功能上的区别,call是批处理的内部命令,它可以将批处理的变量传递到外部程序(一般是批处理),也可以在cmd上启动可执行程序,而start是cmd的内置命令,它的作用仅在于启动某个可执行程序,并不能将批处理的变量传递到外部,从这点上来讲call比start要强大。举例如下: 
 a.bat
 for /l %%i in (1,1,3) do call b.bat %%igoto :eof
 
   a.bat的作用就是三次启动b.bat并把变量%%i传递给b.bat 
 b.bat
 echo number is %1&goto :eof
 
   b.bat就是显示从a.bat中每次传递过来的数字
 
 Last edited by zw19750516 on 2008-3-31 at 02:30 AM ] 
Originally posted by flyhighxu at 2008-3-31 00:00:
 
 Thanks, but call can not only call the commands in the batch itself, but also call external commands. Does it mean that in terms of calling external commands, call and start are both applicable, and their functions overlap?
 
Both call and start can be used to call external commands of batch processing, but there are still differences in functions. Call is an internal command of batch processing. It can pass batch processing variables to external programs (usually batch processing), and can also start executable programs on cmd. While start is a built-in command of cmd. Its function is only to start a certain executable program, and it cannot pass batch processing variables to the outside. In this respect, call is more powerful than start. For example: 
 a.bat
 for /l %%i in (1,1,3) do call b.bat %%igoto :eof
 
   The function of a.bat is to start b.bat three times and pass the variable %%i to b.bat 
 b.bat
 echo number is %1&goto :eof
 
   b.bat is to display the number passed from a.bat each time
 
 Last edited by zw19750516 on 2008-3-31 at 02:30 AM ] 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-3-31 02:16 |  | 
|  | 
 
| flyhighxu 初级用户
 
   
 
 
 
 积分 32
 发帖 11
 注册 2008-3-8
 状态 离线
 | 
| 『第 8 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
非常感谢,说得很详细,很明白 
Thank you very much. It's very detailed and clear. 
 
 
 |  | 
|  2008-3-31 11:08 |  | 
|  | 
 
| cyn01livecn 初级用户
 
   
 
 
 积分 28
 发帖 23
 注册 2010-11-26
 状态 离线
 | 
| 『第 9 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
这个命令咋没用呢?(俺是初学者) 
Why doesn't this command work? (I'm a beginner) 
 
 
 |  | 
|  2010-12-10 17:13 |  | 
|  | 
 
| ingxii 新手上路
 
  
 
 
 
 积分 9
 发帖 8
 注册 2010-11-19
 状态 离线
 | 
| 『第 10 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
今天发现他们很重要的区别start 立即返回
 cal 要等到被调用的程序结束后才返回
 
Today I found a very important difference between them.  start returns immediately.
 cal waits until the called program finishes before returning.
 
 
 
 |  | 
|  2010-12-28 20:53 |  |