Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run a .exe setup from a batch file and recieve its exit code

Posted on 2007-12-03
3
Medium Priority
?
1,913 Views
Last Modified: 2009-01-11
Hi guys,

I have what I hope is a fairly easy question,

Basically I have a batch file which calls the setup.exe file for MSSQL and I would like to be able to detect if the setup ran successfully or abnormally terminated i.e the user canceled it.

Also would it be possible for the following:
1. bat file calls notepad.exe test.txt
2. test.txt doesn't exist, prompts user for creation of said file
3. user hit cancel
4. error code thrown and bat reports back

Any help you guys could provide would be great fully appricated.

Thanks
@ECHO OFF
cd c:\Documents and Settings\dev\Desktop\
start "" /wait setup.exe 
set SETUP_STATUS=%ERRORLEVEL%
echo %SETUP_STATUS%
if %SETUP_STATUS%==0 echo installation success
if not %SETUP_STATUS%==0  echo installation failed

Open in new window

0
Comment
Question by:Black_Omen
2 Comments
 
LVL 5

Expert Comment

by:TheGD
ID: 20505282
Your code seems to be work ok if setup.exe returns a exit code.

Notepad.exe normally does not return any exit code other than 0.
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 400 total points
ID: 21466998
Why not just detect the presence of the text file before running notepad?

Something like this ...
@ECHO OFF
IF NOT EXIST File.txt (
 SET /P CreateFile=File does not exist. Do you want to create it? [Y/N]
 IF /I "Y"=="%CreateFile%" GOTO CreateFile
 GOTO :EOF
)
:CreateFile
Notepad File.txt

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

824 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