China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 12:03
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » (Closed) About how to shield the PAUSE >NUL statement View 1,563 Replies 6
Original Poster Posted 2005-09-13 19:20 ·  中国 辽宁 大连 联通
初级用户
Credits 22
Posts 3
Joined 2005-09-13 00:00
20-year member
UID 42484
Gender Male
Status Offline
Hello everyone:

Currently, I encountered a difficult problem while working on a project.

I wrote a test.bat file:

@ECHO OFF
@ECHO Press any key to exit ...
pause > nul

Now I want to block the pause > nul statement. However, unfortunately, I cannot modify the content of the test.bat file. So, I would like to ask everyone if there is any way to not execute the pause > nul statement when calling the test.bat file?

Thank you all for your help!!!

[ Last edited by willsort on 2005-9-16 at 09:49 ]
Floor 2 Posted 2005-09-13 20:04 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re stonewall:

You can use test.bat to filter out a new batch program and then call it. For example:


find /v /i "pause" < test.bat > %temp%.\_test.bat
call %temp%.\_test.bat
for %%f in (%temp%.\_test.bat*) do del %%f


[ Last edited by willsort on 2005-9-13 at 20:07 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 3 Posted 2005-09-14 14:14 ·  中国 辽宁 大连 联通
初级用户
Credits 22
Posts 3
Joined 2005-09-13 00:00
20-year member
UID 42484
Gender Male
Status Offline
Thanks to the moderator willsort for the reply!
The method you provided I tried and it works well.
But I might be asking for more. Due to business needs, currently I need to call another bat file (xxx.bat) before calling test.bat. Here is its calling sequence.
The content of file fff.bat is as follows:
=============================
xxx.bat
=============================

The content of file xxx.bat is as follows:
=============================
test.bat
...
=============================

The content of file test.bat is as follows:
=============================
@ECHO OFF
@ECHO Press any key to exit ...
pause > nul
...
=============================

The current situation is that the contents of xxx.bat and test.bat I can't modify. I can only modify the content of fff.bat. In this case, I want to block the pause > nul statement in the test.bat file. How can I achieve this by modifying the content of fff.bat?
Moreover, the bad thing is that because there are many operations in xxx.bat, so I can't skip the xxx.bat file.
That is, the fff.bat file must call the xxx.bat file first and then xxx.bat calls test.bat!

In addition, if you have relevant web resources, can you tell me, little brother?
Thanks!

[ Last edited by stonewall on 2005-9-14 at 14:49 ]
Floor 4 Posted 2005-09-14 16:47 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re stonewall:

First, let's talk about a simpler feasible solution: In fff.bat, use cd to change the current path of the batch processing, then filter the result of test.bat to the new current path and name it test.bat, and then call xxx.bat. At this time, the test.bat called in xxx.bat is our customized version.

This solution involves two problems. One is how xxx.bat is called; because the current path has changed, the path needs to be added when calling, but saving and obtaining the original path is more troublesome (under NT series, the original path can be returned by saving the %cd% variable), it is better to directly copy the original xxx.bat to the new path and then jump; the second is how to return to the original current path. After jumping to the new path, returning to the original path still requires saving and obtaining the original path. A simple processing method is to create a subdirectory in the original path, and then use this subdirectory as the new path, and when returning, directly cd.., but the original path may be read-only.

Then talk about another more complicated solution: If the platform you are using is the WinNT series, then you can use the for /f command to filter xxx.bat to get a new batch processing %temp%.\_xxx.bat, in which replace the call of test.bat with the call of %temp%.\_test.bat, then you call %temp%.\_xxxt.bat in fff.bat. If you are using the Win9x/MSDOS series, you can use a third-party command to replace this call string, such as hexc, change, which can also be applied to the WinNT series.

Of course, such a solution has a big turn. If your test.bat call is at the beginning or end of xxx.bat, you can integrate it into fff.bat, placed in the previous or next sentence of the xxx.bat call.

In addition to this, we are left with the difficult problem of "shielding internal commands". If it is at the command line, the macro command of doskey (doskye pause=rem) can be used to achieve, but unfortunately, macro command calls are not supported in batch processing.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 5 Posted 2005-09-14 20:48 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
I'm having a hard time coming up with a reasonable reason for "can't modify xxx.bat and test.bat"? Even if you can't modify it, you can first make a backup of it and then modify it to suit your own use.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 6 Posted 2007-02-14 05:41 ·  中国 浙江 台州 电信
高级用户
★★
DOS学徒
Credits 526
Posts 252
Joined 2007-02-12 05:35
19-year member
UID 79286
Gender Male
Status Offline
Floor 7 Posted 2007-02-15 19:50 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Hehe, if there are no some special commands, you can use test.cmd <nul
Forum Jump: