-
How to hide your program from the Task Manager
This works for XP, VB.NET 2003/2005/2008
This example does not work on Windows Vista.
Add a ListView, and Timer to a form.
{Timer must have the Elapsed vent}
Code:
Public Class Form1
Const WM_COMMAND As Int32 = &H111
Const MF_ENABLED As Int32 = &H0
Const MF_GRAYED As Int32 = &H1
Const LVM_FIRST As Int32 = &H1000
Const LVM_DELETEITEM As Int32 = (LVM_FIRST + 8)
Const LVM_SORTITEMS As Int32 = (LVM_FIRST + 48)
Private Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function apiFindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
Private Declare Function apiEnableWindow Lib "user32" Alias "EnableWindow" (ByVal hwnd As Int32, ByVal fEnable As Int32) As Boolean
Private Declare Function apiGetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Int32) As Int32
Private Declare Function apiGetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Int32, ByVal nPos As Int32) As Int32
Private Declare Function apiGetMenuItemID Lib "user32" Alias "GetMenuItemID" (ByVal hMenu As Int32, ByVal nPos As Int32) As Int32
Private Declare Function apiEnableMenuItem Lib "user32" Alias "EnableMenuItem" (ByVal hMenu As Int32, ByVal wIDEnableItem As Int32, ByVal wEnable As Int32) As Int32
Private Declare Function apiSendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As String) As Int32
Private Declare Function apiGetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Int32
Private Declare Function apiLockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Int32) As Int32
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Me.Text = pName 'Set form name to match process name given
Me.ShowInTaskbar = False 'hide application from taskbar
Timer1.Interval = 700 'Set to start fast
Timer1.Enabled = True 'Actually start the timer
ListView1.View = View.Details
ListView1.Columns.Add("Process name", -2, HorizontalAlignment.Left)
ListView1.Sorting = SortOrder.Ascending 'So that the list view automatically sorts the entries for us.
'Me.Hide() 'uncomment when ready to terminate this program elsehow.
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
HideProcess("", False)
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
HideProcess("explorer", True)
End Sub
Private Function HideProcess(ByVal pName As String, Optional ByVal pHide As Boolean = True)
On Error Resume Next
Dim lhWndParent As Int32 = apiFindWindow(Nothing, "Windows Task Manager") 'get handle to the task manager
Dim lhWndDialog As Int32 = 0
Dim lhWndProcessList As Int32 = 0
Dim lhWndProcessHeader As Int32 = 0
Dim hMenu As Int32 = apiGetMenu(lhWndParent) 'get it's menu handle
Dim hSubMenu As Int32 = apiGetSubMenu(hMenu, 2) 'get it's submenu handle for "View"
Dim hSubSubMenu As Int32 = apiGetSubMenu(hSubMenu, 1) 'get it;s subsub menu handle for "update speed"
Dim hId1 As Int32 = apiGetMenuItemID(hSubMenu, 0) 'Get id for "refresh now" item
Dim hId2 As Int32 = apiGetMenuItemID(hSubSubMenu, 0) 'Get id for "high update speed" item
Dim hId3 As Int32 = apiGetMenuItemID(hSubSubMenu, 1) 'Get id for "normal update speed" item
Dim hId4 As Int32 = apiGetMenuItemID(hSubSubMenu, 2) 'Get id for "low update speed" item
Dim hId5 As Int32 = apiGetMenuItemID(hSubSubMenu, 3) 'Get id for "paused update speed" item
If pHide = True Then
Dim ProcessItemCount, ProcessItemIndex As Int32
Dim itemString As String, p As New Process, Processes() As Process
For i As Int32 = 1 To 7 'Loop through all seven child windows, for handles to the listviews, buttons, and header
lhWndDialog = apiFindWindowEx(lhWndParent, lhWndDialog, Nothing, Nothing)
If lhWndProcessList = 0 Then lhWndProcessList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Processes")
If lhWndProcessHeader = 0 Then lhWndProcessHeader = apiFindWindowEx(lhWndProcessList, 0, "SysHeader32", Nothing)
Next
apiSendMessage(lhWndParent, WM_COMMAND, hId5, 0) 'Click "paused update speed", so we can do it for the taskmgr
apiEnableMenuItem(hMenu, hId1, MF_GRAYED) 'disable refresh now item
apiEnableMenuItem(hMenu, hId2, MF_GRAYED) 'disable high update speed
apiEnableMenuItem(hMenu, hId3, MF_GRAYED) 'disable normal update speed
apiEnableMenuItem(hMenu, hId4, MF_GRAYED) 'disable low update speed
apiEnableMenuItem(hMenu, hId5, MF_GRAYED) 'disable paused update speed
apiEnableWindow(lhWndProcessHeader, 0) 'Disable process header, so it cannot be resorted by user
If Me.ListView1.Items.Count > 0 Then Me.ListView1.Items.Clear() 'clear any old data that was on the list
Processes = Process.GetProcesses() 'Get processes
For Each p In Processes 'Count processes, and add them to the listview.
ProcessItemCount += 1
If p.ProcessName.ToString = "Idle" Then
With Me.ListView1.Items.Add("System Idle Process")
End With
Else
With Me.ListView1.Items.Add(p.ProcessName.ToString)
End With
End If
Next p
'Look for, the index of the process matching the string name of our caption then
For z As Int32 = 0 To ProcessItemCount - 1
itemString = ListView1.Items.Item(z).Text.ToString()
If itemString = pName Then ProcessItemIndex = z
Next
apiLockWindowUpdate(lhWndProcessList) 'Lock the window from updating, to reduce flashing.
apiSendMessage(lhWndParent, WM_COMMAND, hId1, 0) 'AutoClick refresh to update, then immediately sort and delete.
apiSendMessage(lhWndProcessList, LVM_SORTITEMS, 0, Nothing) ' Sort process items alphabetically
apiSendMessage(lhWndProcessList, LVM_DELETEITEM, ProcessItemIndex, 0) 'Delete the process,
apiLockWindowUpdate(False) 'unlock that window
If lhWndParent = 0 Then
If Timer1.Interval <> 800 Then Timer1.Interval = 800 'Set to react fast while task manager is closed.
Else
If Timer1.Interval <> 2500 Then Timer1.Interval = 2500 'Set to a normal looking update speed, while the task manager remains open.
End If
Else
Timer1.Enabled = False 'kill the timer
For i As Int32 = 1 To 7
lhWndDialog = apiFindWindowEx(lhWndParent, lhWndDialog, Nothing, Nothing)
If lhWndProcessList = 0 Then lhWndProcessList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Processes")
If lhWndProcessHeader = 0 Then lhWndProcessHeader = apiFindWindowEx(lhWndProcessList, 0, "SysHeader32", Nothing)
Next
apiEnableMenuItem(hMenu, hId1, MF_ENABLED) 're-enable refresh now
apiEnableMenuItem(hMenu, hId2, MF_ENABLED) 're-enable high update speed
apiEnableMenuItem(hMenu, hId3, MF_ENABLED) 're-enable normal update speed
apiEnableMenuItem(hMenu, hId4, MF_ENABLED) 're-enable low update speed
apiEnableMenuItem(hMenu, hId5, MF_ENABLED) 're-enable paused update speed
apiSendMessage(lhWndParent, WM_COMMAND, hId3, 0) 'click normal update speed
apiSendMessage(lhWndParent, WM_COMMAND, hId1, 0) 'click refresh now
apiEnableWindow(lhWndProcessHeader, 1) 'Enable process header
End If
Return True
End Function
End Class
-
Re: How to hide your program from the Task Manager
Great Code TT(n)! :thumb:
It doesn't seem to like this event (in both 2003 and 2005) :
Code:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
RefreshHide() 'Hide process
End Sub
So I changed Elapsed to Tick was that right ¿
-
Re: How to hide your program from the Task Manager
I dont think Tick will work, or does it?
I'd try setting the timer interval from 750, to something like 1200.
It is a long set of statements i guess.
The RefreshHide sub, has on error resume next which is maybe what your talking about?
Should use a try catch maybe.
But I think it occurs on the first pass only.
-
Re: How to hide your program from the Task Manager
The whole problme is not with the RefreshHide sub, the problem is that it tells me that Event Elapsed cannot be found
Don't you think we should rather create the Timer Dynamically (and add the Elapsed event through the use of the System.Timers namespace), instead of adding a Timer in design View (because by adding the Timer from the Toolbox, it doesn't give the Elapsed event - it only gives Tick and Disposed ) ¿
-
Re: How to hide your program from the Task Manager
Ah,
Open the toolbox, and click on the component tab, and add that timer.
Then click the visual reference to the timer, and it adds the Elapsed event. [Edit: for 2003 only]
\\\///
I found a problem though.
The list view from VB shows "System Idle", as "Idle" which could mess up the order if your process name is greater than the letter i.
I'll have to fix this, to work with all process names.
-
Re: How to hide your program from the Task Manager
That timer, OK - I always was probably a bit naive in thinking why there are two seperate timers in the Toolbox, the "normal" one and the one on the components tab - just glad that confusion is cleared up :D :lol:
Did you edit it in your first post, BTW, just to prevent the same confusion :lol: .Nevermind, I see you did.
On Topic:
I've now got the very same problem you're sitting with, and I can't wait for your update :thumb:
-
Re: How to hide your program from the Task Manager
The code has been updated, and fixed for both problems.
I had forgotten to subract one, from the process count, since it's padded at zero for the first item. Ooops. No prob.
I simply caught the p.ProcessName.ToString, and made an else if condition to add the string System Idle Process, instead of the process name VB gives it "Idle". No prob.
:thumb:
This should work on 2005 now.
I'll install it, and check, so I dont have to keep asking. ;)
-
Re: How to hide your program from the Task Manager
To reduce the flickering of the ListView, I've updated the example with the LockWindowUpdate API. Works perfectly for 2003 and 2005! :wave:
-
Re: How to hide your program from the Task Manager
How can I integrate the Hide part of the code into my program so no timers no listview just hide.
Thanx
-
Re: How to hide your program from the Task Manager
I'm not sure you completely understand what the code is actually doing.
You can however create your own sorting function, to replace the listview.
You can also just hide the listview and or form. A timer is somewhat necessary, and should be fixed to match the task manager's refresh rate.
This gives it the illusion of refreshing/updating at the same time as the preference set, in the task manager's main menu.
I hope you do not missuse this code. :wave:
Thank you
-
Re: How to hide your program from the Task Manager
-
Re: How to hide your program from the Task Manager
-
Re: How to hide your program from the Task Manager
Who are you again?
If you have to ask, then I dont think you really have enough experience to implement it. What I mean is, that our conversation will be and endless cycle of "how do I do that then...", since alot of things are inter-related.
I'm sorry, but I'd encourage you to learn about the basics first.
There is a great set of tutorial links at the top of the forum here.
Microsoft press books, are also extremley helpful at becoming a novice-intermediate programmer. Then you can master anything particular you like!
-
Re: How to hide your program from the Task Manager
I just dont understand this code
Im quite good actually
-
Re: How to hide your program from the Task Manager
Well okay so maybe you know a little bit then.
However, there are explainations on just about every line, which are pretty straight forward.
You can simply uncomment the Me.Hide, so that the listview and form is not visible. Be sure you are ready to terminate the process in some other way, because it will now be invisible to the task manager.
If you insist on dropping the listview, you'll need to hold the information in a string, and perform a simple alphabetic sorting of the process names.
What exactly are you using it for?
-
Re: How to hide your program from the Task Manager
Im Writing an app that i dont want my bro to turn off
-
Re: How to hide your program from the Task Manager
Im using VB 2005
two things:
1st:
i = 1 to 7
comes up with an error should i write
i as integer 1 to 7
will that work????
2nd:
the timer1_elapsed event......handles timer1.elapsed
doesnt exist wot should i write insted???
timer1.tick or timer1.disposed
also can i put this code into form1.vb???or does it have to b in designer.vb???
-
Re: How to hide your program from the Task Manager
Yes the i is already declared as integer. Dont change it.
There should be no error at all here, if you are using my code.
The timer issue, is one of Visual Basic.
They messed up when they rewrote version 2005.
In 2003 a timer from the component tab, would allow an elapsed event.
Before, or now by mistake Microsoft has the wrong timer in the component tab of the tool box.
You can still add the correct timer, by clicking "tool" on the main menu.
Then click choose toolbox items..., then scroll down to the mismatched timer and click the checkbox.
Now add that timer to the project.
The form designer will write the code automatically for you, so for 2005 omit the designer region and start with the constants.
Still works just fine!
Be sure to add to my reputation when you get it working.
Thanks
-
Re: How to hide your program from the Task Manager
It didnt work.
For some reason it didnt work.
No errors just the process shows up!!!
What is happening????
Everything else worked so please help?!?!?!!
-
Re: How to hide your program from the Task Manager
For others who want to try it out I'm just clarifying that in 'Choose Toolbox Items...' search for 'Timer' and check the one that says 'System.Timers' next to it. Uncheck any other Timers.Then readd the timer and goto:
Edit/Quick Replace and type Timer1 into the first box and type Timer2 into the second one.
Thanx
-
Re: How to hide your program from the Task Manager
You've likely made a rookie mistake in haste, and tried to use the debugger(IDE) to test the program.
Quote:
Well how do I do that then...
Please read the red part of my signature below, and follow it's instructions explicitly before every time you release a program.
Be sure to set the process name in the code, to match the process name of the form you want to hide. This will depend on what you named it, during creation ofcourse.
-
Re: How to hide your program from the Task Manager
When you do get it working, they'll be at least two visible differences in the Windows Task Manager.
1. It will show an extra process, in the count at the bottom left corner.
2. Some menu items will be disabled, that are set to update the process information every few seconds.
To view these menu itmes.
Click View on the main menu of the Windows Task Manager
Notice that Refresh Now is disabled.
Then click Update Speed, and notice Windows is actually in a paused position, since the program is updating the contents for it.
These are things for which, I will not show you how to hide.
-
Re: How to hide your program from the Task Manager
It still didnt work even after I published it.
Could you send me a working source file for 2005 to shmuli9@gmail.com???
Thanx
-
Re: How to hide your program from the Task Manager
Look, that is the working source for both 2003/2005.
It works fine, so you've somehow made a mistake following instructions.
As I predicted, this conversation is an endless cycle.
Good luck! :wave:
-
Re: How to hide your program from the Task Manager
Hi TT(n),
i've found two little problems in your code on my local machine (XP Pro).
One problem i haved fixed but the other one is still open.
1. I have to get the wnd handle by
Dim lhWndParent As Integer = apiFindWindow(vbNullString, "Windows Task-Manager")
instead of
Dim lhWndParent As Integer = apiFindWindow(vbNullString, "Windows Task Manager")
2. The handle for Proccess List View dont work:
lhWndProcessList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Processes")
I got always 0. The lhWndDialog seems to be set correct, but it looks like that "Processes" is not found. My OS is running in German. Is this may be a reason (even if this sounds strange).
The process header is correct disabled. Just the handler to the Process List view makes problems.
thanks,
M_B_R
Edit:
OK, i've found it. In fact i have to use the german word instead of "Processes". And a another problem. z is not set to the right position. The value had to be incremented to remove the correct entry.
-
Re: How to hide your program from the Task Manager
Yep, sounds like the German version is a tad different.
:D
-
Re: How to hide your program from the Task Manager
Interesting functionality... Thanks for this.
You can remove the need for the listview altogether by creating a string array and loading it with the process names and then sorting the array alphabetically...
Such as:
Code:
Processes = Process.GetProcesses() 'Get processes
Dim procArray(Processes.Length) As String
For i As Integer = 0 To Processes.Length - 1
procArray(i) = Processes(i).ProcessName
Next
Array.Sort(procArray)
For i As Integer = 0 To procArray.Length - 1
If procArray(i) = HiddenProcessName Then
ProcessItemIndex = i - 1
End If
Next
I've included the full code below, which contains one more thing i changed which is:
Declaring the proper timer object in the class rather than using the designer. This eliminates any confusion on what control to be using.
This should work for anyone that simply copies and paste's the code into an empty form.
Be sure to change the string "HiddenProcessName" with the name of your executable.
Code:
Public Class Form1
Const WM_COMMAND As Integer = &H111
Const MF_ENABLED As Integer = &H0
Const MF_GRAYED As Integer = &H1
Const LVM_FIRST As Integer = &H1000
Const LVM_DELETEITEM As Integer = (LVM_FIRST + 8)
Const LVM_SORTITEMS As Integer = (LVM_FIRST + 48)
Public Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function apiFindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Public Declare Function apiEnableWindow Lib "user32" Alias "EnableWindow" (ByVal hwnd As Integer, ByVal fEnable As Integer) As Integer
Public Declare Function apiGetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Integer) As Integer
Public Declare Function apiGetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
Public Declare Function apiGetMenuState Lib "user32" Alias "GetMenuState" (ByVal hMenu As Integer, ByVal wID As Integer, ByVal wFlags As Integer) As Integer
Public Declare Function apiGetMenuItemID Lib "user32" Alias "GetMenuItemID" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
Public Declare Function apiEnableMenuItem Lib "user32" Alias "EnableMenuItem" (ByVal hMenu As Integer, ByVal wIDEnableItem As Integer, ByVal wEnable As Integer) As Integer
Public Declare Function apiSendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Public Declare Function apiGetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Integer
Public Declare Function apiLockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Integer) As Integer
Dim i As Integer 'For iterating through task manager windows
Dim HiddenProcessName As String = "hidefromtaskmgr" 'Set this name to match the proces name of your application.
Dim WithEvents Timer1 As System.Timers.Timer = New System.Timers.Timer
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 700 'Set to start fast
Timer1.Enabled = True 'Actually start the timer
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Dim lhWndParent As Integer = apiFindWindow(vbNullString, "Windows Task Manager") 'get handle to the task manager
'Declare some handles
Dim lhWndDialog As Integer = 0
Dim lhWndEndTaskButton As Integer = 0
Dim lhWndEndProcessButton As Integer = 0
Dim lhWndProcessList As Integer = 0
Dim lhWndProcessHeader As Integer = 0
Dim lhWndTaskList As Integer = 0
Dim lhWndTaskHeader As Integer = 0
Dim ProcessItemCount As Integer = 0
Dim ProcessItemIndex As Integer = 0
Dim TaskItemCount As Integer = 0
Dim TaskItemIndex As Integer = 0
Dim hMenu As Integer = apiGetMenu(lhWndParent) 'get it's menu handle
Dim hSubMenu As Integer = apiGetSubMenu(hMenu, 2) 'get it's submenu handle for "View"
Dim hSubSubMenu As Integer = apiGetSubMenu(hSubMenu, 1) 'get it;s subsub menu handle for "update speed"
Dim hId1 As Integer = apiGetMenuItemID(hSubMenu, 0) 'Get id for "refresh now" item
Dim hId2 As Integer = apiGetMenuItemID(hSubSubMenu, 0) 'Get id for "high update speed" item
Dim hId3 As Integer = apiGetMenuItemID(hSubSubMenu, 1) 'Get id for "normal update speed" item
Dim hId4 As Integer = apiGetMenuItemID(hSubSubMenu, 2) 'Get id for "low update speed" item
Dim hId5 As Integer = apiGetMenuItemID(hSubSubMenu, 3) 'Get id for "paused update speed" item
For i = 1 To 7
'Loop through all seven child windows, for handles to the listviews, buttons, and header
lhWndDialog = apiFindWindowEx(lhWndParent, lhWndDialog, vbNullString, vbNullString)
If lhWndTaskList = 0 Then
lhWndTaskList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Tasks")
End If
If lhWndTaskHeader = 0 Then
lhWndTaskHeader = apiFindWindowEx(lhWndTaskList, 0, "SysHeader32", vbNullString)
End If
If lhWndEndTaskButton = 0 Then
lhWndEndTaskButton = apiFindWindowEx(lhWndDialog, lhWndTaskList, "Button", "&End Task")
End If
If lhWndProcessList = 0 Then
lhWndProcessList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Processes")
End If
If lhWndProcessHeader = 0 Then
lhWndProcessHeader = apiFindWindowEx(lhWndProcessList, 0, "SysHeader32", vbNullString)
End If
If lhWndEndProcessButton = 0 Then
lhWndEndProcessButton = apiFindWindowEx(lhWndDialog, lhWndProcessList, "Button", "&End Process")
End If
Next
apiSendMessage(lhWndParent, WM_COMMAND, hId5, 0) 'Click "paused update speed", so we can do it for the taskmgr
apiEnableMenuItem(hMenu, hId1, MF_GRAYED) 'disable refresh now item
apiEnableMenuItem(hMenu, hId2, MF_GRAYED) 'disable high update speed
apiEnableMenuItem(hMenu, hId3, MF_GRAYED) 'disable normal update speed
apiEnableMenuItem(hMenu, hId4, MF_GRAYED) 'disable low update speed
apiEnableMenuItem(hMenu, hId5, MF_GRAYED) 'disable paused update speed
apiEnableWindow(lhWndProcessHeader, 0) 'Disable process header, so it cannot be resorted by user
apiEnableWindow(lhWndTaskHeader, 0) 'Disable task header. You could even disable the whole process list.
'apiEnableWindow(lhWndEndProcessButton, 0) 'Disable the end task,
'apiEnableWindow(lhWndEndTaskButton, 0)'and end process buttons. Optional.
Dim Processes() As Process
Dim p As Process
Dim z As Integer
Dim itemString As String
Processes = Process.GetProcesses() 'Get processes
Dim procArray(Processes.Length) As String
For i As Integer = 0 To Processes.Length - 1
procArray(i) = Processes(i).ProcessName
Next
Array.Sort(procArray)
For i As Integer = 0 To procArray.Length - 1
If procArray(i) = HiddenProcessName Then
ProcessItemIndex = i - 1
End If
Next
apiLockWindowUpdate(lhWndProcessList) 'Lock the window from updating, to reduce flashing.
apiSendMessage(lhWndParent, WM_COMMAND, hId1, 0) 'AutoClick refresh to update, then immediately sort and delete.
apiSendMessage(lhWndProcessList, LVM_SORTITEMS, 0, vbNullString) ' Sort process items alphabetically
apiSendMessage(lhWndProcessList, LVM_DELETEITEM, ProcessItemIndex, 0) 'Delete the process,
apiLockWindowUpdate(False) 'unlock that window
If lhWndParent = 0 Then
If Timer1.Interval <> 800 Then
Timer1.Interval = 800 'Set to react fast while task manager is closed.
End If
Else
If Timer1.Interval <> 2500 Then
Timer1.Interval = 2500 'Set to a normal looking update speed, while the task manager remains open.
End If
End If
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Timer1.Enabled = False 'kill the timer
'reset task manager for normal use.
Dim lhWndParent As Integer = apiFindWindow(vbNullString, "Windows Task Manager") 'get handle to the task manager
Dim lhWndDialog As Integer = 0
Dim lhWndEndTaskButton As Integer = 0
Dim lhWndEndProcessButton As Integer = 0
Dim lhWndProcessList As Integer = 0
Dim lhWndProcessHeader As Integer = 0
Dim lhWndTaskList As Integer = 0
Dim lhWndTaskHeader As Integer = 0
Dim hMenu As Integer = apiGetMenu(lhWndParent) 'get it's menu handle
Dim hSubMenu As Integer = apiGetSubMenu(hMenu, 2) 'get it's submenu handle for "View"
Dim hSubSubMenu As Integer = apiGetSubMenu(hSubMenu, 1) 'get it;s subsub menu handle for "update speed"
Dim hId1 As Integer = apiGetMenuItemID(hSubMenu, 0) 'Get id for "refresh now" item
Dim hId2 As Integer = apiGetMenuItemID(hSubSubMenu, 0) 'Get id for "high update speed" item
Dim hId3 As Integer = apiGetMenuItemID(hSubSubMenu, 1) 'Get id for "normal update speed" item
Dim hId4 As Integer = apiGetMenuItemID(hSubSubMenu, 2) 'Get id for "low update speed" item
Dim hId5 As Integer = apiGetMenuItemID(hSubSubMenu, 3) 'Get id for "paused update speed" item
For i = 1 To 7
'Loop through all seven child windows, for handles to the listviews, buttons, and header
lhWndDialog = apiFindWindowEx(lhWndParent, lhWndDialog, vbNullString, vbNullString)
If lhWndTaskList = 0 Then
lhWndTaskList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Tasks")
End If
If lhWndTaskHeader = 0 Then
lhWndTaskHeader = apiFindWindowEx(lhWndTaskList, 0, "SysHeader32", vbNullString)
End If
If lhWndProcessList = 0 Then
lhWndProcessList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Processes")
End If
If lhWndProcessHeader = 0 Then
lhWndProcessHeader = apiFindWindowEx(lhWndProcessList, 0, "SysHeader32", vbNullString)
End If
Next
apiEnableMenuItem(hMenu, hId1, MF_ENABLED) 're-enable refresh now
apiEnableMenuItem(hMenu, hId2, MF_ENABLED) 're-enable high update speed
apiEnableMenuItem(hMenu, hId3, MF_ENABLED) 're-enable normal update speed
apiEnableMenuItem(hMenu, hId4, MF_ENABLED) 're-enable low update speed
apiEnableMenuItem(hMenu, hId5, MF_ENABLED) 're-enable paused update speed
apiSendMessage(lhWndParent, WM_COMMAND, hId3, 0) 'click normal update speed
apiSendMessage(lhWndParent, WM_COMMAND, hId1, 0) 'click refresh now
apiEnableWindow(lhWndProcessHeader, 1) 'Enable process header
apiEnableWindow(lhWndTaskHeader, 1) 'Enable task header
End Sub
End Class
-
Re: How to hide your program from the Task Manager
Quote:
Declaring the proper timer object in the class rather than using the designer.
This eliminates any confusion on what control to be using.
Ironically, my original intention was to not confuse novice users, that would be more familiar with the designer. :)
But since the 2003 and 2005 designers don't agree, then maybe it is best to use a timer object.
Quote:
This should work for anyone that simply copies and paste's the code into an empty form.
Perhaps, because that was the intent.
What I mean is, that you still may have someone asking questions about how they should put it into their Non-default existing program or form.
The problem is, that their project's properties may treat potential errors as actual errors. In the case where they've changed the error sensitivities, but dont know why they did, or how to work with resolving these trivial issues, that they've self-imposed. Uhhgg.
Thanks for the minor update! :thumb:
The code was a bit messy anyway, so maybe I'll rewrite it somtime with multi-language abilities already coded within it, and a few extras I've come up with.
-
Re: How to hide your program from the Task Manager
This example does not work on Windows Vista, at least as it is now.
-
Re: How to hide your program from the Task Manager
Does this code work for other processes like the internet Explorer or do u have to change the code some how
-
Re: How to hide your program from the Task Manager
Yes it did, and should work for any process name.
Change the string "HiddenProcessName", to iexplorer, on this line:
Code:
Dim HiddenProcessName As String = "iexplorer" 'Set this name to match the proces name of your application.
Be sure not to use the debugger, when testing this.
Test it as a built executable file, in the release folder.
-
Re: How to hide your program from the Task Manager
I am using your code. Its working fine.
But it is not working in Vista.
Plz help me regarding this. Its very urgent for me.
-
Re: How to hide your program from the Task Manager
I'm sorry the code doesn't work on Vista.
I can't help you either, because I don't know of a way to do it without being malicious.
-
How to hide your program from the MSconfig startup
Hi,
I created appliction which is start at system startup. Then it is showing in the MSconfig startup. Is there ay way so that i can hide from MSconfig?
Plz reply on this.
-
Re: How to hide your program from the Task Manager
Hi all Guru,
Ur code helped me for my GameGuard. But pls help me to fix the code so that it can work on Vista or Win7?
Pls!!!
-
Re: How to hide your program from the Task Manager
Sorry. We can't do that...
-
Re: How to hide your program from the Task Manager
danghieunhoc, this thread is 2 years old.
Please start a new thread that links to this thread.
-
Re: How to hide your program from the Task Manager
in VB6 you used to be able to do a single API call which would make windows think your app was a screensaver and would therefore not show up in any task manager-style programs at all.
Can you not still just do this with VB.NET?
-
Re: How to hide your program from the Task Manager
-
Re: How to hide your program from the Task Manager
Why oh why does this thread keep on being revived :confused:
I am closing it now.
If there is a question abot something in this thread, start a new thread in reference to this thread.
Hannes