Solved

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

Posted on 2013-01-23
2
1,218 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
2 Comments
 
LVL 82

Accepted Solution

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

Open in new window

0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now