title: How to restart IIS on remote windows server from windows 7 client machine?
body: <p>I am trying to restart iis remotely (Windows Servr 2012) from my local machine (Windows 7). The below command in command line doesn't work to restart IIS;</p>
  
  <pre><code>    iisreset servername /restart
  </code></pre>
  
  <p>but the below command works fine when I tried in command line.</p>
  
  <pre><code>    psexec iisreset \\servername /restart
  </code></pre>
  
  <p>Now the issue is when I try with below code in C#,</p>
  
  <pre><code>    Process process = new Process();
      ProcessStartInfo startInfo = new ProcessStartInfo();
      startInfo.WindowStyle = ProcessWindowStyle.Hidden;
      startInfo.FileName = "cmd.exe";
      startInfo.Arguments = "\C psexec iisreset \\servername /restart";
      startInfo.RedirectStandardOutput = true;
      startInfo.UseShellExecute = false;
      process.StartInfo = startInfo;
      process.Start();
      // capture what is generated in command prompt
      var output = process.StandardOutput.ReadToEnd();
  </code></pre>
  
  <p>If I give any other arguments in the above code like 'ipconfig', it gives me the expected output. But when I try with psexec, it gives empty output. But it works well when tried in command prompt.</p>
  
  <p>I have also tried by using 'psexec.exe' in the filename and by removing '\C psexec' in the arguments. But still no luck.</p>
  
  <p>Could you please anyone help me to resolve this?</p>
  
  <p>Thanks in Advance.</p>