• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1835
  • Last Modified:

How to execute CommandLine arguments ?

I'd like to know how to execute commandline arguments for instance 'netsend ', 'copy' from Delphi.

I've tried ShellExec :

ShellExecute(Application.Handle,'Open',PChar(CommandLine),'','',SW_HIDE)

and this seems to work fine for opening an exe but not for executing a single task like netsend or copy.

Regards
Andre

0
AndreDicks
Asked:
AndreDicks
1 Solution
 
szjozsefCommented:
For that you need to run the command interpreter (command.com or cmd.exe) with the parameter /c <command name), eg. copy , net ...


Best Regards,
JSz.
0
 
ntonyCommented:
what about

UINT WinExec(

    LPCSTR  lpszCmdLine,     // address of command line
    UINT  fuCmdShow      // window style for new application
   );


i think that's what you need!
0
 
ntonyCommented:
For Win32-based applications, use the CreateProcess function. (Microsoft)
0
 
Mohammed NasmanSoftware DeveloperCommented:
szjozsef  is right
you need to use command.com /c switch

ShellExecute(Application.Handle,'Open',PChar('command.com /c netsend pc1 hi),'','',SW_HIDE)
0
 
AndreDicksAuthor Commented:
ntony

Thx

Regards
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now