Hack Forums
[C#] Hide Console App when executed. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Hide Console App when executed. (/showthread.php?tid=6148656)



Hide Console App when executed. - PitbullT0r - Apr 10, 2021

(EDITED)
Founded the solutions.
Go on Property -> Output -> Windows Application.


RE: Hide Console App when executed. - HOMODIN - Apr 10, 2021

(Apr 10, 2021 12:53 AM)PitbullT0r Wrote:  (EDITED)
Founded the solutions.
Go on Property -> Output -> Windows Application.

Thanks for the update :D
Depending on what you want to run there's other ways too, personally I use .vbs for it ;)


RE: Hide Console App when executed. - PitbullT0r - Apr 10, 2021

(Apr 10, 2021 01:43 AM)HOMODIN Wrote:  Thanks for the update :D
Depending on what you want to run there's other ways too, personally I use .vbs for it ;)

Ahahah i just searched for it and update for other newbies like me.


RE: Hide Console App when executed. - Exalted - Apr 10, 2021

Just an addition, you can also edit your .csproj file directly and change the OutputType from Exe to WinExe to achieve this.

Code
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>WinExe</OutputType>
    </PropertyGroup>

</Project>



RE: Hide Console App when executed. - PitbullT0r - Apr 10, 2021

(Apr 10, 2021 03:00 AM)Exalted Wrote:  Just an addition, you can also edit your .csproj file directly and change the OutputType from Exe to WinExe to achieve this.

Code
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>WinExe</OutputType>
    </PropertyGroup>

</Project>

Okay thanks, really usefull.
Im just learning this beatiful programming language, i like it so much.


RE: Hide Console App when executed. - Mistercoenkel - Jun 15, 2021

Code
[DllImport("kernel32.dll")]
private static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

private const int SW_HIDE = 0;
private const int SW_SHOW = 5;

public static void Main(string[] args)
{
   var handle = GetConsoleWindow();

   // Hide Console
   ShowWindow(handle, SW_HIDE);

   // Show Console
   // ShowWindow(handle, SW_SHOW);

}