Board index » delphi » Exec ->Access denied ?

Exec ->Access denied ?

Hi there!

I have a question with calling Exec procedure in BP ( Target - Real mode ).
Consider thefollowing situation :

SwapVectors;
Exec('c:\','s.bat'+Param);
SwapVectors;
Case DosError of
   ...
   5:writeln('Access denied');
end;

Thank you.

Alexzander

 

Re:Exec ->Access denied ?


In article <01bcca07$2a2e7200$76eb2...@teacher2.insart.kharkov.ua>,
U...@insart.kharkov.ua says...

Quote

>Hi there!

>I have a question with calling Exec procedure in BP ( Target - Real mode ).
>Consider thefollowing situation :

>SwapVectors;
>Exec('c:\','s.bat'+Param);
>SwapVectors;
>Case DosError of
>   ...
>   5:writeln('Access denied');
>end;

>Thank you.

>Alexzander

Hi!

First: the correct systax for Exec is:
Procedure Exec(Path, CmdLine: String);

'Path' is the (full or partial) path of the file to run.
'CmdLine' is the command line.

Second:
Do not try to run batch files with Exec!!! The Exec can run only binary
files (com, exe). This may cause a system crash!

Try this: Exec('COMMAND.COM /C c:\s.bat',Param);

BandiT

Re:Exec ->Access denied ?


Quote
"User" <U...@insart.kharkov.ua> wrote:
>I have a question with calling Exec procedure in BP ( Target - Real mode ).
>Consider thefollowing situation :

>SwapVectors;
>Exec('c:\','s.bat'+Param);
>SwapVectors;

This is one of those times where you are seeing what should be
there rather than what is there.  ;-)

If you check online help for Exec, then carefully look at your
statement you should see what you've done wrong.  You should
also get Timo's FAQ <ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip>.
The example discussed for item 9: Shelling from a TP program
will show you exactly what you are doing wrong.

For want of something better, let's assume "Param" contains
'/s'.  The error would then be attempting to load and execute
"C:\" with parameters "s.bat/s"

Exec maps to DOS's int 21, Function 4Bh - Load and Execute
Program.  You can load and execute .EXE and .COM files, but
batch files are be executed through the command shell.  
Try:  Exec(GetEnv('COMPSEC'), '/c s.bat '+param);

    ...red

--
Support the anti-Spam amendment
  Join at http://www.cauce.org/

Re:Exec ->Access denied ?


Re:Exec ->Access denied ?


On 1997-09-26 U...@insart.kharkov.ua said:
 Us{Newsgroups: comp.lang.pascal.borland
 Us{X-Newsreader: Microsoft Internet News 4.70.1155
 Us{Hi there!
 Us{I have a question with calling Exec procedure in BP ( Target - Real
 Us{mode ). Consider thefollowing situation :
 Us{SwapVectors;
 Us{Exec('c:\','s.bat'+Param);
 Us{SwapVectors;
 Us{Case DosError of
 Us{...
 Us{5:writeln('Access denied');
 Us{end;
 Us{Thank you.
 Us{Alexzander
Try this:
EXEC( 'C:\' + 'S.BAT', PARAM );

aiding.serv...@oystre-slidre.mail.telia.com

Net-Tamer V 1.08 - Test Drive

Re:Exec ->Access denied ?


In article <3476d09...@d2o201.telia.com>,

Quote
 <aiding.serv...@oystre-slidre.mail.telia.com> wrote:

>On 1997-09-26 U...@insart.kharkov.ua said:
> Us{Newsgroups: comp.lang.pascal.borland
> Us{X-Newsreader: Microsoft Internet News 4.70.1155
> Us{Hi there!
> Us{I have a question with calling Exec procedure in BP ( Target - Real
> Us{mode ). Consider thefollowing situation :
> Us{SwapVectors;
> Us{Exec('c:\','s.bat'+Param);
> Us{SwapVectors;
> Us{Case DosError of
> Us{...
> Us{5:writeln('Access denied');
> Us{end;
> Us{Thank you.
> Us{Alexzander
>Try this:
>EXEC( 'C:\' + 'S.BAT', PARAM );

Joking?

EXEC cannot execute BAT-files. One needs the command processor. Try:

exec(getenv('comspec'),'/e:1024 /c c:\s');

The /e is for environment size. If the bat-file does not set any
(temporary) environment variables then you cat leave it out. If you
have bigger environment than 1024 you can increase it.

Osmo

Other Threads