Board index » delphi » Pascal Exec command in Windows XP Environment

Pascal Exec command in Windows XP Environment

Hi @All,

i want to program in turbo pascal a tool to add windows 2000 users.
The problem is that the exec-procedure returns dos error-codes (2,3,5 or 8).
I've tried different syntax and methods but i did not suceed.

Can you tell me the syntax for executing the file "net.exe" in
an windows 2000 environment?

It could be also a problem concerning the memory management under windows 2000.
Then is there an alternative to Exec()-Procedure?

Thanky for your help!

Stefan

 

Re:Pascal Exec command in Windows XP Environment


"Stefan Ha?denteufel" <SHassdenteu...@t-online.de> schreef in bericht
news:85b5314d.0305301359.77db0bb6@posting.google.com...

Quote
> Hi @All,

> i want to program in turbo pascal a tool to add windows 2000 users.
> The problem is that the exec-procedure returns dos error-codes (2,3,5
or 8).
> I've tried different syntax and methods but i did not suceed.

> Can you tell me the syntax for executing the file "net.exe" in
> an windows 2000 environment?

> It could be also a problem concerning the memory management under
windows 2000.
> Then is there an alternative to Exec()-Procedure?

normally

Swapvectors;
exec(getenv('comspec'),' /c net.exe');
Swapvectors;

does the trick

getenv('comspec')

returns the name and address of the command.com program or the
equivalent in the windows version you are using.

/C

means that you are calling the command program for executing a command,
and the command is a call to the program.
This way I can start most windows programs. Sometimes a program needs
the START command, e.g.

swapvectors;
exec(getenv('COMSPEC'),'/C start WMPLAYER.exe
c:\windows\media\ding.wav');
swapvectors;

hth
--
Femme

Re:Pascal Exec command in Windows XP Environment


Quote
"Femme Verbeek" <fv[at]{*word*104}jet[dot]nl> wrote in message <news:vdfmcirbho69cb@corp.supernews.com>...
> "Stefan Ha?denteufel" <SHassdenteu...@t-online.de> schreef in bericht
> news:85b5314d.0305301359.77db0bb6@posting.google.com...
> > Hi @All,

> > i want to program in turbo pascal a tool to add windows 2000 users.
> > The problem is that the exec-procedure returns dos error-codes (2,3,5
>  or 8).
> > I've tried different syntax and methods but i did not suceed.

> > Can you tell me the syntax for executing the file "net.exe" in
> > an windows 2000 environment?

> > It could be also a problem concerning the memory management under
>  windows 2000.
> > Then is there an alternative to Exec()-Procedure?

> normally

> Swapvectors;
> exec(getenv('comspec'),' /c net.exe');
> Swapvectors;

> does the trick

> getenv('comspec')

> returns the name and address of the command.com program or the
> equivalent in the windows version you are using.

> /C

> means that you are calling the command program for executing a command,
> and the command is a call to the program.
> This way I can start most windows programs. Sometimes a program needs
> the START command, e.g.

> swapvectors;
> exec(getenv('COMSPEC'),'/C start WMPLAYER.exe
> c:\windows\media\ding.wav');
> swapvectors;

> hth

Thank you for your answer. I tried it and each run doserror 8. I think
it has to do something with the memory, is that right?

Here is my source-code:

program test;

uses dos;

begin
swapvectors;
exec(Getenv('comspec'),'/c start c:\net.exe');
swapvectors;
writeln(doserror);
readln;
end.

Hopes this helps...

HDT

Re:Pascal Exec command in Windows XP Environment


"Stefan Ha?denteufel" <SHassdenteu...@t-online.de> schreef in bericht
news:85b5314d.0305302122.79ca3493@posting.google.com...

Quote
> "Femme Verbeek" <fv[at]{*word*104}jet[dot]nl> wrote in message

<news:vdfmcirbho69cb@corp.supernews.com>...

Quote
> > "Stefan Ha?denteufel" <SHassdenteu...@t-online.de> schreef in
bericht
> > news:85b5314d.0305301359.77db0bb6@posting.google.com...
> > > Hi @All,

> > > i want to program in turbo pascal a tool to add windows 2000
users.
> > > The problem is that the exec-procedure returns dos error-codes
(2,3,5
> >  or 8).
> > > I've tried different syntax and methods but i did not suceed.

> > > Can you tell me the syntax for executing the file "net.exe" in
> > > an windows 2000 environment?

> > > It could be also a problem concerning the memory management under
> >  windows 2000.
> > > Then is there an alternative to Exec()-Procedure?

> > normally

> > Swapvectors;
> > exec(getenv('comspec'),' /c net.exe');
> > Swapvectors;

> > does the trick

> > getenv('comspec')

> > returns the name and address of the command.com program or the
> > equivalent in the windows version you are using.

> > /C

> > means that you are calling the command program for executing a
command,
> > and the command is a call to the program.
> > This way I can start most windows programs. Sometimes a program
needs
> > the START command, e.g.

> > swapvectors;
> > exec(getenv('COMSPEC'),'/C start WMPLAYER.exe
> > c:\windows\media\ding.wav');
> > swapvectors;

> > hth

> Thank you for your answer. I tried it and each run doserror 8. I think
> it has to do something with the memory, is that right?

> Here is my source-code:

add the fololowing line

Quote
> program test;

  {$M 8192,0,0}

Quote
> uses dos;

> begin
> swapvectors;
> exec(Getenv('comspec'),'/c start c:\net.exe');
> swapvectors;
> writeln(doserror);
> readln;
> end.

By default TP reserves all the dos memory remaining for itself, unless
you tell him to leave some room for other programs.

This is an exerpt from the BP help file

  DosError (variable)     (WinDos unit and Dos unit)
  ___________________________________________________
 DosError is used by many of the routines in the Dos and
 WinDos units to report errors.

  var DosError: Integer;  {Error status variable}

 The values stored in DosError are DOS error codes.

 A value of 0 indicates no error; other possible error
 codes are as follows:

  Code | Meaning
  -----?------------------
    2  | File not found
    3  | Path not found
    5  | Access denied
    6  | Invalid handle
    8  | Not enough memory
   10  | Invalid environment
   11  | Invalid format
   18  | No more files

hth

--
Femme

Re:Pascal Exec command in Windows XP Environment


JRS:  In article <85b5314d.0305302122.79ca3...@posting.google.com>, seen
in news:comp.lang.pascal.borland, Stefan Ha?denteufel <SHassdenteufel@t-
online.de> posted at Fri, 30 May 2003 22:22:55 :-

Quote

>Here is my source-code:

>program test;

>uses dos;

>begin
>swapvectors;
>exec(Getenv('comspec'),'/c start c:\net.exe');
>swapvectors;
>writeln(doserror);
>readln;
>end.

Read TSFAQP #9, especially the line marked (* <-- Important *).

If you use TSFAQP before posting here, you can save us time.
If you use TSFAQP before programming, you can save yourself time.

--
 ? John Stockton, Surrey, UK.  ?...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt>   RAH Prins : c.l.p.b mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re:Pascal Exec command in Windows XP Environment


Quote
"Femme Verbeek" <fv[at]{*word*104}jet[dot]nl> wrote in message <news:vdh5dkklido209@corp.supernews.com>...
> "Stefan Ha?denteufel" <SHassdenteu...@t-online.de> schreef in bericht
> news:85b5314d.0305302122.79ca3493@posting.google.com...
> > "Femme Verbeek" <fv[at]{*word*104}jet[dot]nl> wrote in message
>  <news:vdfmcirbho69cb@corp.supernews.com>...
> > > "Stefan Ha?denteufel" <SHassdenteu...@t-online.de> schreef in
>  bericht
> > > news:85b5314d.0305301359.77db0bb6@posting.google.com...
> > > > Hi @All,

> > > > i want to program in turbo pascal a tool to add windows 2000
>  users.
> > > > The problem is that the exec-procedure returns dos error-codes
>  (2,3,5
>  or 8).
> > > > I've tried different syntax and methods but i did not suceed.

> > > > Can you tell me the syntax for executing the file "net.exe" in
> > > > an windows 2000 environment?

> > > > It could be also a problem concerning the memory management under
>  windows 2000.
> > > > Then is there an alternative to Exec()-Procedure?

> > > normally

> > > Swapvectors;
> > > exec(getenv('comspec'),' /c net.exe');
> > > Swapvectors;

> > > does the trick

> > > getenv('comspec')

> > > returns the name and address of the command.com program or the
> > > equivalent in the windows version you are using.

> > > /C

> > > means that you are calling the command program for executing a
>  command,
> > > and the command is a call to the program.
> > > This way I can start most windows programs. Sometimes a program
>  needs
> > > the START command, e.g.

> > > swapvectors;
> > > exec(getenv('COMSPEC'),'/C start WMPLAYER.exe
> > > c:\windows\media\ding.wav');
> > > swapvectors;

> > > hth

> > Thank you for your answer. I tried it and each run doserror 8. I think
> > it has to do something with the memory, is that right?

> > Here is my source-code:

> add the fololowing line

> > program test;

>   {$M 8192,0,0}

> > uses dos;

> > begin
> > swapvectors;
> > exec(Getenv('comspec'),'/c start c:\net.exe');
> > swapvectors;
> > writeln(doserror);
> > readln;
> > end.

> By default TP reserves all the dos memory remaining for itself, unless
> you tell him to leave some room for other programs.

Thanky for your help. It works fine now!

Other Threads