Solved

Batch/VBscript to check if file exists, if exists run another batch

Posted on 2013-01-23
2
1,266 Views
Last Modified: 2013-01-23
Hello,

I am looking for a batch/vbscript file to check a directory if a file exists, if the file exists, call another batch file.  If it doesn't exist, exit.

Something like "if exist "C:\test.txt" run "c:\runme.bat " ELSE exit"

Can't seem to get the above to work.

Thank you.
0
Comment
Question by:cbones
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 38811427
Close:
if exist "C:\test.txt" (call "c:\runme.bat") ELSE (exit)

Open in new window

0
 
LVL 70

Expert Comment

by:Qlemo
ID: 38811452
The parens are essential, but I won't use    (exit)    , as that closes the cmd window. It is better to use    (exit /b)   to only exit from the current batch file.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question