Home All Groups Group Topic Archive Search About

Command Prompt or Windows

Author
13 Oct 2006 2:12 PM
TBoon
Hi there,

A console application (.exe) can be executed at Command Prompt or Windows
(double-click).
Is there a way to detect  whether if it is executed at CP or Windows?

regards,
Boon

Author
13 Oct 2006 5:58 PM
GhostInAK
Hello TBoon,

I believe your assumption is wrong.  I'm fairly certain that you can not
operate in both console and GUI mode from a single app.
This effect is usually accomplished by providing a ".com" console app that
is the equivalent of the ".exe" GUI app.  You can ask Windows for the launching
process.. search google or MSDN for details.

-Boo

Show quoteHide quote
> Hi there,
>
> A console application (.exe) can be executed at Command Prompt or
> Windows
> (double-click).
> Is there a way to detect  whether if it is executed at CP or Windows?
> regards,
> Boon
Author
13 Oct 2006 6:53 PM
Oenone
GhostInAK wrote:
> I believe your assumption is wrong.  I'm fairly certain that you can
> not operate in both console and GUI mode from a single app.

My guess was that he's only ever operating in console mode, but he wants to
tell whether his application was launched by someone opening a command
window and typing in "myapp.exe" in order to run in the existing window, or
by double-clicking the .exe in Windows so that it automatically opened a
console window to run the application.

The only way I could think to do this would be to see what the name of the
process that launched the application is (presumably it would be either
explorer.exe or cmd.exe) but I've no idea how one would find that
information.

--

(O)enone
Author
16 Oct 2006 5:18 PM
GhostInAK [Bastard]
Hello Oenone,

Unfortunately not everyone uses the Explorer shell or the cmd console.  Some
people change their GUI shells (to somethink like Elightenment for Windows
or whatever) and some people use MSH instead of CMD. 

Unless you can guarantee your target audience will always and forever use
explorer and cmd, you need to find another way.  I don't have a way off the
top of my head.

-Boo

Show quoteHide quote
> GhostInAK wrote:
>
>> I believe your assumption is wrong.  I'm fairly certain that you can
>> not operate in both console and GUI mode from a single app.
>>
> My guess was that he's only ever operating in console mode, but he
> wants to tell whether his application was launched by someone opening
> a command window and typing in "myapp.exe" in order to run in the
> existing window, or by double-clicking the .exe in Windows so that it
> automatically opened a console window to run the application.
>
> The only way I could think to do this would be to see what the name of
> the process that launched the application is (presumably it would be
> either explorer.exe or cmd.exe) but I've no idea how one would find
> that information.
>