Solved

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

Posted on 2007-12-03
3
1,884 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
3 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:
RQuadling earned 100 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
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…

747 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

9 Experts available now in Live!

Get 1:1 Help Now