home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
pcmag
/
vol8n01.arc
/
EXECDEMO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-10-06
|
1KB
|
50 lines
{$M 1024,0,0}
PROGRAM Exec_Demo;
(*By Neil J. Rubenking*)
(*Demonstrates the use of new TP 5.0 routines *)
(*to enhance the EXEC procedure. *)
USES Dos;
VAR
WhatProg, Found : PathStr;
BEGIN
Write('Enter the program name just as you');
WriteLn(' would at the DOS prompt, with NO');
Write('extension and NO path. It can be a ');
WriteLn('COM, EXE, or BAT file.');
Write('Program name:');
ReadLn(WhatProg);
Found := FSearch(WhatProg+'.COM','');
IF Found = '' THEN
Found := FSearch(WhatProg+'.EXE','');
IF Found = '' THEN
Found := FSearch(WhatProg+'.BAT','');
IF Found = '' THEN
Found := FSearch(WhatProg+'.COM', GetEnv('PATH'));
IF Found = '' THEN
Found := FSearch(WhatProg+'.EXE', GetEnv('PATH'));
IF Found = '' THEN
Found := FSearch(WhatProg+'.BAT', GetEnv('PATH'));
IF Found = '' THEN
BEGIN
WriteLn('Sorry, I cannot find "',WhatProg,'" anywhere!');
Halt(1);
END;
Found := FExpand(Found);
WriteLn('Press <Return> to execute ',Found);
ReadLn;
SwapVectors;
IF Pos('.BAT',Found) > 0 THEN
EXEC(GetEnv('COMSPEC'),'/C '+Found)
ELSE
EXEC(Found,'');
SwapVectors;
CASE DosError OF
0 : WriteLn('Successful completion');
1 : WriteLn('Invalid function');
2 : WriteLn('File not found or path invalid.');
5 : WriteLn('Access denied.');
8 : WriteLn('Insufficient memory.');
END;
END.