How do I hide a process in Task Manager in C#?
There is no supported way to accomplish this. The process list can be read at any privilege level. If you were hoping to hide a process from even Administrators, then this is doubly unsupported.
To get this to work, you would need to write a kernel mode rootkit to intercept calls to NtQuerySystemInformation so that the SystemProcessInformation info class fails to list your hidden process.
Intercepting system calls is very difficult to do safely, and the 64 bit Windows kernels go out of their way to prevent this from being possible: trying to modify the syscall table results in an instant blue screen. It's going to be very difficult on those platforms
Here is an example of a rootkit that tries to do something similar (and has several serious problems).
Is it possible to hide winform in TaskManager application tab?
Try something like this
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.ShowInTaskbar = false;
}
protected override CreateParams CreateParams {
get {
var cp = base.CreateParams;
cp.ExStyle |= 0x80; // Turn on WS_EX_TOOLWINDOW
return cp;
}
}
}
Hide a C# program from the task manager?
Not that I'm aware of - and there shouldn't be. The point of the task manager is to allow users to examine processes etc.
If the user should be able to do that, they should be able to find your program. If they shouldn't be poking around in Task Manager, group policy should prevent that - not your program.
how to hide .net app from process list
It's definitely possible to hide a process; you're talking about designing a rootkit. If that's actually what you want to do, see this question.
It's usually not the right way to approach this problem however: if you're the admin of a machine and you don't wish other users to kill a process, you simply don't give them permissions to do it.
Have your users log on with a limited user account and have your application run under a different account.
To get logon time reliably, you can use some either the windows security logs or if you're on a domain, active directory services:
Getting Local Windows User login session timestamp in C#
Getting idle time is more complicated because it depends on what you consider "idle" to be, but if you consider GetLastInputInfo()
sufficient, this question describes a good way to do it, with a user process reporting back to a system process:
Getting user Idle time in C#?
Since the user cannot kill the system process, you could have that watch the user process and recreate it if necessary.
Launch process and hide command line parameters from Task Manager
There's no way to pass a command line argument to a process, so that the process can see it, but everything else in the system cannot.
This is an obvious flaw and when programs allow passwords to be passed as arguments, it's usually done for convenience for the user that is not concerned about eavesdroppers. Well designed programs will usually provide, in addition, other secure means of authentication.
Related Topics
Why Use Icollection and Not Ienumerable or List<T> on Many-Many/One-Many Relationships
ASP.NET MVC 5 - Identity. How to Get Current Applicationuser
Why Are Extension Methods Only Allowed in Non-Nested, Non-Generic Static Class
Why Does the Equals Implementation for Anonymous Types Compare Fields
Can Timers Get Automatically Garbage Collected
Is There Any Benefit to This Switch/Pattern Matching Idea
Observeon and Subscribeon - Where the Work Is Being Done
Return View as String in .Net Core
Ignore Mapping One Property with Automapper
Are There Any Fuzzy Search or String Similarity Functions Libraries Written for C#
Algorithm to Compare Two Images in C#
Xml Serialization and Inherited Types
Getfiles with Multiple Extensions
C# Using Reflection to Copy Base Class Properties
Creating a Zip Archive in Memory Using System.Io.Compression
Multiple Actions Were Found That Match the Request in Web API