如果存在未在批次工作 [英] if exist not working in batch

查看:105
本文介绍了如果存在未在批次工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我努力使创建一个简单的文本文件.bat文件。我的问题是Windows XP中的主文件夹 C:\\ Documents和Settings ,而Vista和高于 C:\\ Users \\ <用户/ code>

I am trying to make a .bat file that creates a simple text file. My problem is Windows XP home folder is C:\Documents and Settings while vista and above its C:\Users\

我运行这一点,不管是什么,我把用于路径名,我总是存在

I am running this and no matter what I put for the path name, I always get it exists

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

当我运行上面我得到存在的时候,其实它并没有因为我的Windows 7我在做什么错了?

When I run the above I get it exists when in fact it does not since I am windows 7. What am I doing wrong?

推荐答案

首先,你缺少的路径周围的引号。第二个 EXIST 如果只检查存在的文件。有几个秘密的文件时,Windows将使用其文件系统。请尝试以下操作:

Firstly, you are missing quotes around the path. Second EXIST only checks if files exist. There are a few secret files Windows uses in its file system. Try the following:

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

这篇关于如果存在未在批次工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆