Solved

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

Posted on 2013-01-23
2
1,259 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 84

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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