I need to hide the taskbar and start button via a Windows service.
In a console program I can successfully call FindWindow and/or EnumWindows to get the "Shell_TrayWnd" window and then hide it using ShowWindow(hwnd, SW_HIDE).
But when the service performs FindWindow("Shell_TrayWnd", NULL) it returns NULL, and when the service performs EnumWindows it gets an incomplete list which does not include the "Shell_TrayWnd" window.
Can anyone suggest how a service can see the "Shell_TrayWnd" window, or suggest an alternative method for hiding the taskbar and start button (that works in a service)? Thanks.
The correct way to provide a UI (or otherwise interact with UI elements) for a service is to provide a GUI client that runs in the user's context and uses some IPC method (possibly RPC, possibly message-passing) to communicate with the service. UI processing within privileged services is and always has been a security hole.
If you simply want a computer-wise process to kill the taskbar, then a service is neither needed nor helpful. Configure a scheduled task to run at login. Or set the registry to launch a custom shell instead of explorer.exe. You aren't doing anything that requires privilege other than the user's own account.
To avoid blinking a console window, build your program for the WINDOWS subsystem, or use editbin /SUBSYSTEM:WINDOWS to change the flags in the PE header after build is complete.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With