![]() |
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-06 01:24 |
48,039 topics / 350,124 posts / today 2 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » How can a batch file open a new window |
| Printable Version 1,478 / 9 |
| Floor1 ZJHJ | Posted 2007-10-06 21:01 |
| 高级用户 Posts 374 Credits 609 | |
|
When running a.bat, I want b.bat to open in a new window. After b.bat finishes running, a.bat should then continue. (I can't use call, because if b.bat runs in the same window, the program in b.bat will stop working)
|
|
| Floor2 lxmxn | Posted 2007-10-06 23:20 |
| 版主 Posts 4,938 Credits 11,386 | |
| Floor3 ZJHJ | Posted 2007-10-07 00:44 |
| 高级用户 Posts 374 Credits 609 | |
|
Thanks, moderator!
Opening a new window does work now, but problem 1: the new window can't close automatically. Problem 2: a.bat only continues after pressing n. Problem 3: the program in b.bat still does not execute (stops working) Actually, in a.bat I executed once: cd.>t.txt for /f "delims=" %%i in (a.txt) do ( if not defined %%i set %%i=A & echo %%i>>t.txt ) But a bit later I still need to execute this again: cd.>t2.txt for /f "delims=" %%k in (a2.txt) do ( if not defined %%k set %%k=B & echo %%k>>t2.txt ) The problem is: the second execution absolutely refuses to write to t2.txt. |
|
| Floor4 lxmxn | Posted 2007-10-07 02:40 |
| 版主 Posts 4,938 Credits 11,386 | |
| Floor5 ZJHJ | Posted 2007-10-07 09:12 |
| 高级用户 Posts 374 Credits 609 | |
|
Thank you very much, enthusiastic moderator!
Using your start /wait cmd /c b.bat really did solve problem 1, the new window not closing automatically, and problem 2, a.bat only continuing after pressing n. But problem 3, the program in b.bat still not executing (stopping working), still has not been solved. I don't know why. At first I put cd.>t.txt for /f "delims=" %%i in (a.txt) do ( if not defined %%i set %%i=A & echo %%i>>t.txt ) and cd.>t2.txt for /f "delims=" %%k in (a2.txt) do ( if not defined %%k set %%k=B & echo %%k>>t2.txt ) in the same bat for execution, and found that it would not write data to t2.txt. Later I split them into a.bat and b.bat, and after running a.bat and then b.bat, both executed normally, which is why I asked my original question. Now the problem of not writing data to t2.txt is still not solved. |
|
| Floor6 lxmxn | Posted 2007-10-07 18:33 |
| 版主 Posts 4,938 Credits 11,386 | |
|
I tested it separately yesterday. I simulated your program, wrote data, and there was no problem.
Maybe there is something wrong with your program. Post it and let us take a look. Also, multiple bat files can all be integrated into one bat for execution, there's no need to split them into several. |
|
| Floor7 ZJHJ | Posted 2007-10-07 21:10 |
| 高级用户 Posts 374 Credits 609 | |
| Floor8 ZJHJ | Posted 2007-10-07 23:04 |
| 高级用户 Posts 374 Credits 609 | |
| Floor9 lxmxn | Posted 2007-10-07 23:19 |
| 版主 Posts 4,938 Credits 11,386 | |
|
A solution has already been given in the batch file section, you can refer to it.
|
|
| Floor10 ZJHJ | Posted 2007-10-08 11:12 |
| 高级用户 Posts 374 Credits 609 | |
|
Many thanks to Mr. lxmxn!
Your setlocal and endlocal commands solved the problem of having cd.>t.txt for /f "delims=" %%i in (a.txt) do ( if not defined %%i set %%i=A & echo %%i>>t.txt ) and cd.>t2.txt for /f "delims=" %%k in (a2.txt) do ( if not defined %%k set %%k=B & echo %%k>>t2.txt ) in the same program. Thanks again!! But it still did not solve the problem in the program I posted. However, it already solved more than half of it for me. Using your setlocal and endlocal commands, I made structural adjustments to the original program, removed one step, and achieved what I wanted. Thanks again!! 2007.10.08.11 |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |