Recent

Author Topic: Bug on TProcess with internal command?  (Read 6989 times)

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Bug on TProcess with internal command?
« on: July 19, 2010, 08:56:03 am »
Hi,
i'm using the code in this wiki: http://wiki.lazarus.freepascal.org/Executing_External_Programs#An_Improved_Example

I've only changed this line:
Code: [Select]
AProcess.CommandLine := 'ppc386 -h';
with this:
Code: [Select]
AProcess.CommandLine := 'dir r:';
Running the program i have this error:
Code: [Select]
Failed to execute dir r: : 2.
It's a bug with internal command?

Thanks, Mario

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Bug on TProcess with internal command?
« Reply #1 on: July 19, 2010, 09:32:08 am »
Quote
It's a bug with internal command?
No, since TProcess isn't a shell and it's platform independent. It doesn't have any internal commands.

You can use cmd's /K option to do this, e.g.:
Code: [Select]
AProcess.CommandLine := 'cmd /K dir r:';

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Bug on TProcess with internal command?
« Reply #2 on: July 20, 2010, 06:26:07 pm »
I've used "cmd /c" instead of "cmd /k", and now works.
Thanks for your help, Mario

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Bug on TProcess with internal command?
« Reply #3 on: July 21, 2010, 12:53:50 pm »
Quote
I've used "cmd /c" instead of "cmd /k", and now works.
Oops, sorry. I've got them mixed in my head :P

Bart

  • Hero Member
  • *****
  • Posts: 5664
    • Bart en Mariska's Webstek
Re: Bug on TProcess with internal command?
« Reply #4 on: July 22, 2010, 02:41:24 pm »
And this will fail under win9x of course.

Bart

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Bug on TProcess with internal command?
« Reply #5 on: July 22, 2010, 03:14:48 pm »
I haven't a PC with win9x, but i think that you must use "command.com /c"

Hi, Mario

Bart

  • Hero Member
  • *****
  • Posts: 5664
    • Bart en Mariska's Webstek
Re: Bug on TProcess with internal command?
« Reply #6 on: July 23, 2010, 11:59:18 am »
In the good old days of DOS you would inspect the value of the environmentvariable COMSPEC.

This environmentvariable still exists in WinXP (and "points to" cmd.exe), not sure about later Windows versions though.

Bart

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2671
Re: Bug on TProcess with internal command?
« Reply #7 on: July 24, 2010, 03:37:16 am »
yup

Quote
....
ComSpec=C:\WINDOWS\system32\cmd.exe
....

(XP64)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018