Solved

Getting the Errorlevels wich a childprocess returns

Posted on 2001-06-10
1
265 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
ID: 6172947
Use DosExitCode instead of DosError...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Extract small icon from a TMemoryStream or TIcon 3 720
DevExpress TcxDBLookupComboBox accent insensitive 2 977
WebCam and Delphi 2 2,563
.dat problems 39 200
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

12 Experts available now in Live!

Get 1:1 Help Now