如果不存在 - CMD命令 - 不工作 [英] If Not Exist - CMD Command - Not Working

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

问题描述

我目前正在写一个执行安装文件的批处理文件。它运行安装文件之前,我检查是否该目录存在,以避免重新安装应用程序。

I am currently writing a batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application.

我用如果站点不存在文件名语句做到这一点。如果已安装的文件不存在,我然后执行安装文件。

I do this by using a If Not Exists filename statement. If the installed file doesn't exist, I then execute the installation file.

由于某些原因,当我在那里已经安装该应用程序测试了一下,仍试图在它重新安装应用程序。

For some reason, when I test it with the application where it has been installed already, it is still trying to reinstall the application over it.

下面是我的code的一个片段:

Here is a snippet of my code:

cd "C:\Documents and Settings\John\Start Menu\Programs\"
pause
If NOT exist "Software Folder"\ (
 start \\filer\repo\lab\"software"\"myapp"\setup.exe
 pause
) 

其中, SoftwareFolder 子目录。C:\\ Documents和Settings \\约翰\\开始菜单\\程序\\我检查,看它是否在我的程序文件夹存在。

Where SoftwareFolder is a subdirectory of "C:\Documents and Settings\John\Start Menu\Programs\". I am checking to see if it exists in my Programs folder.

我知道没有什么是错我的启动命令。我有一种感觉的东西是错误与我开始 CD 命令或它的参数。

I know nothing is wrong with my start command. I have a feeling something is wrong with my beginning CD command or its parameters.

非常感谢你们!

推荐答案

使用该文件夹的完整路径在你的。如果不存在code。然后,你甚至不会有CD了:

Use the FULL path to the folder in your If Not Exist code. Then you won't even have to CD anymore:

If Not Exist "C:\Documents and Settings\John\Start Menu\Programs\SoftWareFolder\"

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

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