Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-12-03
3
Medium Priority
?
1,908 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
[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
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:
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
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 …
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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