Improve company productivity with a Business Account.Sign Up

x
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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