BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Open cmd.exe from shortcut, execute command

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
vortic
Guest





PostPosted: Sun Oct 15, 2006 1:02 am    Post subject: Open cmd.exe from shortcut, execute command Reply with quote



I have a VCL form application, and on a button onClick Event, I want to open
a shortcut (CmdShortcut) pointing to cmd.exe, and run some command window
application (SomeApp.exe) within the command window. I have no idea how to
do this because I can't seem to use the online help very effectively. I
can't even figure out how to execute any app or get a command line.

I'm using Turbo C++ Explorer on XP SP2.

Any help appreciated.

p.s. Should have I posted this to cppbuilder.language.cpp ??
Back to top
Jonathan Benedicto
Guest





PostPosted: Sun Oct 15, 2006 3:53 am    Post subject: Re: Open cmd.exe from shortcut, execute command Reply with quote



vortic wrote:
Quote:
I have a VCL form application, and on a button onClick Event, I want to
open a shortcut (CmdShortcut) pointing to cmd.exe, and run some command
window application (SomeApp.exe) within the command window. I have no idea
how to do this because I can't seem to use the online help very
effectively. I can't even figure out how to execute any app or get a
command line.

You can either use ShellExecute or CreateProcess.

Eg:

ShellExecute( NULL, "open", "myapp.exe", "", NULL, SW_SHOWDEFAULT );

Quote:
p.s. Should have I posted this to cppbuilder.language.cpp ??

No, this is the correct group.

HTH

Jonathan
Back to top
vortic
Guest





PostPosted: Sun Oct 15, 2006 5:59 am    Post subject: Re: Open cmd.exe from shortcut, execute command Reply with quote



"Jonathan Benedicto" <invalid (AT) nobody (DOT) com> wrote in message
news:45316a45$1 (AT) newsgroups (DOT) borland.com...
Quote:
vortic wrote:
I have a VCL form application, and on a button onClick Event, I want to
open a shortcut (CmdShortcut) pointing to cmd.exe, and run some command
window application (SomeApp.exe) within the command window. I have no idea
how to do this because I can't seem to use the online help very
effectively. I can't even figure out how to execute any app or get a
command line.

You can either use ShellExecute or CreateProcess.

Excellent. I open Cmd.exe instead of the app directly, as I like to run it
through a command window because the app auto closes and I like to look at
the output. I could not figure out how to get ShellExecute to open a
shortcut, but that is ok.

Thanks,
vortic
Back to top
Michel Leunen
Guest





PostPosted: Sun Oct 15, 2006 2:31 pm    Post subject: Re: Open cmd.exe from shortcut, execute command Reply with quote

vortic wrote:

Quote:
I could not figure out how to get ShellExecute to open a
shortcut, but that is ok.

A shortcut is like other files and has an .lnk extension. Just do

ShellExecute( NULL, "open", "your_link.lnk", "", NULL, SW_SHOWDEFAULT );

Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
http://www.leunen.com/
----------------------------------------
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Oct 16, 2006 10:24 pm    Post subject: Re: Open cmd.exe from shortcut, execute command Reply with quote

"vortic" <vortic (AT) users (DOT) sourceforge.net> wrote in message
news:4531423c$1 (AT) newsgroups (DOT) borland.com...

Quote:
I have a VCL form application, and on a button onClick Event, I want
to open a shortcut (CmdShortcut) pointing to cmd.exe

You do not need to execute the shortcut. You can execute cmd.exe itself
directly. Use the CreateProcess() function for that.

Quote:
and run some command window application (SomeApp.exe) within the command
window.


Then you do not need to run cmd.exe at all. You can run SomeApp.exe
directly instead. If it is a console application, then it will show the
console window automatically.


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Oct 16, 2006 10:27 pm    Post subject: Re: Open cmd.exe from shortcut, execute command Reply with quote

"vortic" <vortic (AT) users (DOT) sourceforge.net> wrote in message
news:453187e4$1 (AT) newsgroups (DOT) borland.com...

Quote:
I open Cmd.exe instead of the app directly, as I like to run it through
a command window because the app auto closes and I like to look
at the output.

If you use CreateProcess() to run the console application directly, you can
capture the output and display it in your own program. CreateProcess()
allows you to assign your own handles for STDIN/STDOUT/STDERR. So your
program could use CreatePipe() to create handles for STDOUT and STDERR, and
then use ReadFile() to receive any data the console application outputs.


Gambit
Back to top
vortic
Guest





PostPosted: Tue Oct 17, 2006 8:10 am    Post subject: Re: Open cmd.exe from shortcut, execute command Reply with quote

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message >
Quote:
"vortic" >> I open Cmd.exe instead of the app directly, as I like to run
it through
a command window because the app auto closes and I like to look
at the output.

If you use CreateProcess() to run the console application directly, you
can
capture the output and display it in your own program. CreateProcess()
allows you to assign your own handles for STDIN/STDOUT/STDERR. So your
program could use CreatePipe() to create handles for STDOUT and STDERR,
and
then use ReadFile() to receive any data the console application outputs.


Perfect. This is exactly what I really want anyway. I'll give this a shot.

Thanks Remy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.