1

I have a console App, I want to hide it from Task Manager while running.

Amir Hamdy
  • 21
  • 1
  • 8

1 Answers1

1

If you want to hide the Console App from App(s) list in Task Manager

Try this :

using System;
using System.Runtime.InteropServices;

namespace SampleConsoleTest
{
    class Program
    {

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


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


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

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


            // Hide
            ShowWindow(handle, SW_HIDE);


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

            Console.ReadKey();
        }
    }
}

This does not show the app in App List, but is visible in process(s) list.


It's about hiding a process from Task Manager.

One of the common approach is injecting process into another : How to hide C# application from taskmanager processtab?

Here is a detailed answer on how you can achieve it : How do I hide a process in Task Manager in C#?

Community
  • 1
  • 1
Parimal Raj
  • 20,189
  • 9
  • 73
  • 110