『第 4 楼』:
使用 LLM 解释/回答一下
Re stonewall:
先说简单一些的可行性方案:在 fff.bat 中用 cd 改变批处理的当前路径,然后将test.bat 过滤结果置于新的当前路径下,并名为 test.bat,然后再调用 xxx.bat ,此时在 xxx.bat 调用的 test.bat 便是我们自定义的版本了。
这种方案牵涉到两个问题,一是 xxx.bat 如何调用;因为当前路径改变,所以调用时需加上路径,但保存和获取原来的路径是比较麻烦的(在NT系列下可以通过保存 %cd% 变量来返回原路径),不如直接将原 xxx.bat 拷贝至新路径下后再跳转;第二是如何返回到原来的当前路径,跳转到新路径后,返回原路径仍需保存和获取元路径,简单的处理办法是,在原路径下新建子目录,然后以此子目录为新路径,返回时直接cd..即可,但有可能原路径是只读的。
再说另一个复杂一些的方案:如果你所应用的平台是 WinNT 系列,那么可以使用 for /f 命令过滤 xxx.bat ,得到一个新的批处理 %temp%.\_xxx.bat ,在其中将 test.bat 的调用替换为 %temp%.\_test.bat 的调用,然后你在 fff.bat 中调用 %temp%.\_xxxt.bat 。如果你使用的是 Win9x/MSDOS 系列,可以使用第三方命令,替换这个调用串,比如 hexc,change,它们也可以应用于 WinNT 系列中。
当然,这样的解决方案,转折是大了一些。如果你的 test.bat 调用位于 xxx.bat 的首部或尾部,倒可以将它整合进 fff.bat 中,放在 xxx.bat 调用的前一句或后一句。
除此而外,我们仅余直面“屏蔽内部命令”这一难题,如果在命令行,倒可以用 doskey 的宏命令(doskye pause=rem)实现,可惜在批处理中不支持宏命令的调用。
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.
|