Solved

Getting the Errorlevels wich a childprocess returns

Posted on 2001-06-10
1
264 Views
Last Modified: 2010-04-16
Hi,

I'm running a childprocess with the exec command and these programs return an errorlevel.
Is there a way to get these in my Pascal program? (In a batchfile I can ask them with the errorlevel 'function?')
I don't need to return the doserror but the errorlevel.

Function ShellCommand(Command : String) : Integer;
Var
  Redirect        : Boolean;
  OutputTo        : String;
Begin
  Redirect := (Pos('>', Command) <> 0);
  If Redirect Then
    OutputTo := ''
  Else
    OutputTo := ' >nul';
  SwapVectors;
  Exec(GetEnv('COMSPEC'), '/C ' + Command + OutputTo);
  SwapVectors;
  ShellCommand := DosError;
End;

0
Comment
Question by:Rcm
1 Comment
 
LVL 14

Accepted Solution

by:
AvonWyss earned 2 total points
Comment Utility
Use DosExitCode instead of DosError...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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

6 Experts available now in Live!

Get 1:1 Help Now