Originally posted by qinbuer at 2007-6-8 12:51 PM:
如果只要求最小化,那么
@echo off
start %0 /min
这样不是很简洁?
首先,直接start %0 /min 并不能启动原来的批处理,需要start "" %0 /min 之类的;
第二,/min放到后面是无效的,放到前面start /min "" %0;
第三,直接执行这个代码会产生递归效果,而且直接使用start调用bat的话,并不是平常的cmd /c而是cmd /k来执行批处理,就是批处理运行完所有代码后不会退出,这样就会使得cmd窗口弹出一大堆,可以试试,死机别说我……
To楼上:
%1 %2是上次start调用批处理时传递的启动参数:
start /min /i "" "%~nx0" goto min
这里%1和%2分别对应goto和min了;
那么被start调用的批处理执行%1 %2时就等于执行goto min,就跳转到:min标签而不再次执行start以免产生递归效果
Originally posted by qinbuer at 2007-6-8 12:51 PM:
If only minimizing is required, then
@echo off
start %0 /min
Isn't this very concise?
First, directly start %0 /min cannot start the original batch processing; it needs to be start "" %0 /min and so on;
Second, /min placed at the back is invalid; placing it at the front start /min "" %0;
Third, directly executing this code will produce a recursive effect, and directly using start to call bat is not cmd /c but cmd /k to execute the batch processing. That is, after the batch processing runs all the code, it will not exit, which will make the cmd window pop up a lot. You can try it, don't say I caused a crash...
To the above:
%1 %2 are the startup parameters passed when the last start called the batch processing:
start /min /i "" "%~nx0" goto min
Here %1 and %2 correspond to goto and min respectively;
Then when the batch processing called by start executes %1 %2, it is equivalent to executing goto min, which jumps to the :min label without executing start again to avoid the recursive effect