Install and uninstall windows service via command prompt "C#"
<p>i want install and uninstall win service via command prompt "C#"</p>

<p>following code is not working please help me</p>

<pre><code>string strInstallUtilPath ="C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\";
string strInstallService = " InstallUtil.exe \"D:\\TestUser\\ServiceForPatch\\TestService\\bin\\Debug\\TestService.exe\"";                           
ProcessStartInfo PSI = new ProcessStartInfo("cmd.exe");
PSI.RedirectStandardInput = true;
PSI.RedirectStandardOutput = true;
PSI.RedirectStandardError = true;
PSI.UseShellExecute = false;
Process p = Process.Start(PSI);
System.IO.StreamWriter SW = p.StandardInput;
System.IO.StreamReader SR = p.StandardOutput;
SW.WriteLine(@"cd\");         
SW.WriteLine(@"cd " + strInstallUtilPath);
SW.WriteLine(strInstallService);
p.WaitForExit(); 
SW.Close();
</code></pre>
