Results 1 to 6 of 6

Thread: Executing commandline commands

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Executing commandline commands

    Hi,

    I'm trying to execute command line commands. This would be nice for my console.

    So far I got it working that I can execute application and batch files. Console output is redirected to my in-game console. The only thing that doesn't work is executing commands like "dir" and "cd". (If I put these in a .bat file, it works fine)

    thnx

    ps: this is how you capture console output pipeline: http://delphi.about.com/cs/adptips20...ltip0201_2.htm
    NecroSOFT - End of line -

  2. #2

    Executing commandline commands

    Internal shell commands need to be executed with the shell. That's why it works with batchfiles.

    Executing with shell looks like cmd /c "dir".

    You can do this by using

    executeprocess(getenvironmentstring('COMSPEC').['/c','dir']);

    Also, have a look at the process unit (I have that one also running under Delphi, it is easy to port).

  3. #3
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Executing commandline commands

    Thanks

    I will try that soon.

    Thanks for you comment.
    NecroSOFT - End of line -

  4. #4
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Executing commandline commands

    thanks, I tried some things, no I work with the prefix 'cmd /C'. You pushed my in the right direction. It works now
    NecroSOFT - End of line -

  5. #5

    Executing commandline commands

    Quote Originally Posted by NecroDOME
    thanks, I tried some things, no I work with the prefix 'cmd /C'. You pushed my in the right direction. It works now
    getenvironmentvariable('COMSPEC') will return cmd on windows NT/2k/XP/vista and command.com on win9x and dos. (that don't have cmd.exe), and some dos shell under OS/2 too.

    IOW, it is slightly more portable than hardcoding it

  6. #6
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Executing commandline commands

    It's only for debuggin purpose, checking some thing in-game, nothing spectacular that will be in the production code.
    NecroSOFT - End of line -

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •