title: Starting a list of processes with XX.MainModule.FileName
body: <p>I have a program with a checkbox which allows users to select as many currently running processes as they want, and monitor them and then restart them if they go down. </p>
  
  <p>I have the monitoring part done, it checks if they are in</p>
  
  <pre><code>Process.GetProcesses()
  </code></pre>
  
  <p>every X seconds. </p>
  
  <p>then displays:</p>
  
  <pre><code>  listBox1.Items.Add(itemChecked + @" " + @"is running" + @" " + DateTime.Now);
  </code></pre>
  
  <p>but if they are not running I'm trying to get the process file path like this: </p>
  
  <pre><code>foreach (object itemChecked in checkedListBox1.CheckedItems)
  
              {
                  var retVal = Process.GetProcesses().Any(p =&gt; p.ProcessName == itemChecked.ToString());
  
                  if (retVal.Equals(true))
                  {
                      listBox1.Items.Add(itemChecked + @" " + @"is running" + @" " + DateTime.Now);
                  }
  
                  else if (retVal.Equals(false))
                  {
                      listBox1.Items.Add(itemChecked + @" " + @"is not running, attempting to start" + @" " + DateTime.Now);
                      Process[] processList = Process.GetProcessesByName(itemChecked.ToString());
  
                      foreach (Process theProcess in processList)
                      {
                       Process.Start(theProcess.MainModule.FileName.ToString());
                      }
                  }
              }
  </code></pre>
  
  <p>With this code nothing happens if they are not running apart from telling me it's not running. Any ideas? </p>