Execute program if it is not running already

<?xml version="1.0" encoding="utf-8"?>
<xsharper xmlns="">
    <versionInfo title="RunIfNot" value="Run a program if a certain top-level window does not exist." Version="" Copyright="(C) 2009 DeltaX Inc." />
    <usage options="ifNoArguments | default" />
    <param name="process-name" required="true">Process name, w/o .exe. For example, 'explorer'</param>
    <param name="title-wildcard" required="true">Wildcard to match window title (if starts with ^ - treat as regex)</param>
    <param name="command-line" required="true" count="multiple" last="true">Command line to execute if the window is not found</param>
        using System.Runtime.InteropServices;
        using System.Diagnostics;
        static class Native {
            [DllImport("user32.dll", SetLastError = true)]
            public static extern bool BringWindowToTop(IntPtr hWnd);

            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool SetForegroundWindow(IntPtr hWnd);
        XS.StringFilter sf=new XS.StringFilter(c.GetStr("title-wildcard"));
        foreach (Process p in Process.GetProcessesByName(c.GetStr("process-name")))
            if (sf.IsMatch(p.MainWindowTitle))
                return 0;
    <shell mode="shellExecute" wait="false"><param>${command-line}</param></shell>