Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理中缺少“搜索”参数_Batch File - Fatal编程技术网

Batch file 批处理中缺少“搜索”参数

Batch file 批处理中缺少“搜索”参数,batch-file,Batch File,我在我的批处理文件中有这个,它可以工作。我的问题是,我在不同的计算机上使用它,但它们存储符号的方式不同 @ECHO === Checking for Symantech Products IF NOT EXIST "C:\Program Files\Symantec" GOTO DoneSymantec ECHO One moment while we remove Symantec Software... Call "%~d0\exe\Norton_Removal_Tool.exe" :Don

我在我的批处理文件中有这个,它可以工作。我的问题是,我在不同的计算机上使用它,但它们存储符号的方式不同

@ECHO === Checking for Symantech Products
IF NOT EXIST "C:\Program Files\Symantec" GOTO DoneSymantec
ECHO One moment while we remove Symantec Software...
Call "%~d0\exe\Norton_Removal_Tool.exe"
:DoneSymantec
所以我的问题是,有没有这样的方法:如果不存在*程序文件中包含norton或symantech的任何文件夹转到donesymantech

dir/b/s/ad c:\program files\symantec将递归搜索文件夹symantec,从c:\program files开始

选中%errorlevel%,如果找到,则为0;如果未找到,则为1

理论上,您可以从C:\开始,但这需要相当长的时间才能完成。 如果您知道从何处开始搜索示例中的c:\program文件,则速度会快得多

如果需要,请在C:\Program Files x86中启动第二次搜索,而不是只在整个磁盘上进行一次搜索

如果不想看到dir的输出,只需将其重定向到nirwana>nul。这也会加快搜索速度,因为打印到屏幕上的速度相当慢

编辑:如果您需要路径,而不是只知道是否存在:

for /F "delims=" %%j in ('dir /b /s /ad "c:\Program Files\symantec" "c:\Program Files (x86)\symantec"') do @echo %%j

在程序文件和x86程序文件中搜索;根据需要进行调整

+1以达到目的……我建议使用%ProgramFiles%和%ProgramFilesx86%使脚本驱动器和语言可移植