Search code examples
c#.netpopupsuppress

Suppress Process Popup in .NET


Our user panel runs all of our software as services. For whatever reason though, the Mumble voice software creates a popup when you run it with an administrator password set in the command line. Someone posted an alternative by using a bat file that runs two processes as a work around, but is there any way to just suppress the popup message using .NET? I have written a lot of launcher type apps to fix things like this, but I have no idea how I could suppress this message.

Here is what the .bat file looks like from the workaround.

set /p VAR= < superadmin.txt
start murmur2.exe -supw %var%
ping 0.0.0.0 -n 3 > NUL
tskill murmur2
murmur.exe

Solution

  • You can try to monitor open windows and close popup via winapi when it shows up

    [DllImport("user32.dll")]
    public static extern int FindWindow(string lpClassName, string lpWindowName);
    
    [DllImport("user32.dll")]
    public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
    
    public const int WM_COMMAND = 0x0112;
    public const int WM_CLOSE = 0xF060;
    
    int handle = FindWindow(lpClassName, lpWindowName);
    SendMessage(handle, WM_COMMAND, WM_CLOSE, 0);