Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-01-23
2
Medium Priority
?
1,318 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 2000 total points
ID: 38811427
Close:
if exist "C:\test.txt" (call "c:\runme.bat") ELSE (exit)

Open in new window

0
 
LVL 71

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

618 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