Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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_Operating System - Fatal编程技术网

Batch file 如果存在,则不能批量工作

Batch file 如果存在,则不能批量工作,batch-file,operating-system,Batch File,Operating System,我正在尝试创建一个.bat文件来创建一个简单的文本文件。我的问题是Windows XP主文件夹是C:\Documents and Settings,而vista及其以上的C:\Users\ 我正在运行它,无论我为路径名输入什么,我总是得到它存在的 @echo off if exist C:\Documents and Settings\ ( echo it exists Pause ) else ( echo file not found Pause ) 当我运

我正在尝试创建一个.bat文件来创建一个简单的文本文件。我的问题是Windows XP主文件夹是
C:\Documents and Settings
,而vista及其以上的
C:\Users\

我正在运行它,无论我为路径名输入什么,我总是得到它存在的

@echo off
if exist C:\Documents and Settings\ (
    echo it exists
    Pause
) else (
    echo file not found
    Pause
)

当我运行上面的程序时,我得到
它存在
,而事实上它不存在,因为我是Windows7。我做错了什么?

首先,您缺少路径周围的引号。第二个
EXIST
仅检查文件是否存在。Windows在其文件系统中使用了一些机密文件。请尝试以下操作:

@echo off
if exist "C:\Documents and Settings\NUL" (
    echo it exists
    Pause
) else (
    echo Folder not found
    Pause
)

首先,路径周围缺少引号。第二个
EXIST
仅检查文件是否存在。Windows在其文件系统中使用了一些机密文件。请尝试以下操作:

@echo off
if exist "C:\Documents and Settings\NUL" (
    echo it exists
    Pause
) else (
    echo Folder not found
    Pause
)

嗯,这个目录存在于Windows7中。只是藏起来了。键入“dir/ac:\”查看它。它说它是一个连接点。那是什么?如果我在资源管理器的设置中使用c:\Documents,它会显示文件夹不是foundUm,该目录存在于Windows7中。只是藏起来了。键入“dir/ac:\”查看它。它说它是一个连接点。那是什么?如果我在资源管理器的设置中使用c:\Documents,它会显示文件夹未找到+1完整答案。NUL不是一个“秘密文件”,它只是一种检查文件夹是否存在的方法。文件夹可能为空。+1完整答案。NUL不是一个“秘密文件”,它只是一种检查文件夹是否存在的方法。文件夹可能为空。