Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I played around with this a little but didn't have complete success. I was able to determine which windows were incognito, and from there, technically kill the process.</p> <p>However, it appears the chrome executable has to be killed to close the actual window, which unfortunately closes all the chrome windows. </p> <p>You may be able to get something like SendKeys to simulate an Alt-F4 using the windows handle, or if I'm not mistaken, .Net 4.5 has some additional closing routines you could try. </p> <p>Nonetheless, here is the code to determine which windows are chrome and which of those are incognito. They then "kill", but it doesn't close the window, just kills the browsing (Aw, Snap! as Chrome puts it).</p> <pre><code> [DllImport("user32.dll")] static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam); [DllImport("user32.dll")] static extern bool CloseWindow(IntPtr hWnd); [DllImport("user32")] private static extern bool SetForegroundWindow(IntPtr hwnd); public const int WM_SYSCOMMAND = 0x0112; public const int SC_CLOSE = 0xF060; private void button1_Click(object sender, EventArgs e) { var proc = Process.GetProcesses().OrderBy(x =&gt; x.ProcessName); foreach (Process prs in proc) if (prs.ProcessName == "chrome" &amp;&amp; WmiTest(prs.Id)) { prs.Kill(); //To test SendKeys, not working, but gives you the idea //SetForegroundWindow(prs.Handle); //SendKeys.Send("%({F4})"); } } private bool WmiTest(int processId) { using (ManagementObjectSearcher mos = new ManagementObjectSearcher(string.Format("SELECT CommandLine FROM Win32_Process WHERE ProcessId = {0}", processId))) foreach (ManagementObject mo in mos.Get()) if (mo["CommandLine"].ToString().Contains("--disable-databases")) return true; return false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload