2

I wrote an executable that displays a window on the screen and gets some use input. It is bound to ⊞ Win+N:

#n:: Run "C:\Perso\dev-perso\dly\dly.exe"

My problem: this also opens a cmd (or PS) console which sometimes covers the actual program:

enter image description here

Is there a way to start an executable without the associated console?

I tried, per the documentation, to use the Hide or Min parameter, but this alters the behaviour of both programs, not only the console.

2 Answers 2

3

There are two types of Windows applications : Graphical or console. If the executable is a console application, then it would automatically display a CMD window as its output when started.

Windows needs to know before the program starts running which subsystem it's going to use. Once the program has started running, it's not possible to go back and request the other mode. In programming, the difference is in the definition of the main procedure of the program.

Your program is of the console subsystem, probably because it's much simpler to program (doesn't need a message pump). A console program can hide its own console by using the GetConsoleWindow function with the ShowWindow function.

The specific code for implementing this is up to you, or you can ask for details on Stack Overflow which is the place for programming questions.

1
  • 1
    Thank you for pointing me to the right direction! This is a Go program and adding -ldflags -H=windowsgui during the build fixed the issue. Thanks!
    – WoJ
    Apr 19 at 13:17
0

I am coding in Java; compile it executable by GraalVM native.
To hide console I have to do another step, after constructing executable.

  1. lets say I compiled the project 'com.tugalsan.gvm.cloud' to a native executable as 'com.tugalsan.gvm.cloud.exe '.

  2. First I am copying the executable as with a 'noconsole' tag with the cmd below:

copy com.tugalsan.gvm.cloud.exe com.tugalsan.gvm.cloud.noconsole.exe
  1. Then I am running 'editbin.exe' as below.
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\editbin.exe" /SUBSYSTEM:WINDOWS com.tugalsan.gvm.cloud.noconsole.exe
1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 20 at 8:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .