中国DOS联盟论坛

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-03 13:02
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » (Closed) About how to shield the PAUSE >NUL statement
Printable Version  1,564 / 6
Floor1 stonewall Posted 2005-09-13 19:20
初级用户 Posts 3 Credits 22
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 ]
Floor2 willsort Posted 2005-09-13 20:04
元老会员 Posts 1,512 Credits 4,432
Re stonewall:

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



[ Last edited by willsort on 2005-9-13 at 20:07 ]
Floor3 stonewall Posted 2005-09-14 14:14
初级用户 Posts 3 Credits 22
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 ]
Floor4 willsort Posted 2005-09-14 16:47
元老会员 Posts 1,512 Credits 4,432
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.
Floor5 Climbing Posted 2005-09-14 20:48
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
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.
Floor6 gne3 Posted 2007-02-14 05:41
高级用户 Posts 252 Credits 526
Floor7 everest79 Posted 2007-02-15 19:50
金牌会员 Posts 1,127 Credits 2,564
Hehe, if there are no some special commands, you can use test.cmd <nul
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023