R
Royston
I tried to reset IIS thru Web using the following code
ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
// Redirect both streams so we can write/read them.
si.RedirectStandardInput = true;
si.RedirectStandardOutput = true;
si.UseShellExecute = false;
// Start the procses.
Process p = Process.Start(si);
p.StandardInput.WriteLine("iisreset","/restart");
p.StandardInput.WriteLine("exit");
// Read all the output generated from it.
string output = p.StandardOutput.ReadToEnd();
StreamWriter writer = new StreamWriter(alertLog, true, Encoding.UTF8);
writer.WriteLine(DateTime.Now + ": \"" + output);
writer.Close();
The code work in Windows 2000 server, the output is
Attempting stop...
Internet services successfully stopped
Attempting start...
Internet services successfully restarted
but when I run the code in Windows 2003 Enterprise Edition, the iisreset
don't work and I get
1/12/2005 3:33:24 PM: "Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
c:\windows\system32\inetsrv>iisreset
Access denied, you must be an administrator of the remote computer to use
this
command. Either have your account added to the administrator local group of
the remote computer or to the domain administrator global group.
c:\windows\system32\inetsrv>exit
Do anyone know how to solve this?
ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
// Redirect both streams so we can write/read them.
si.RedirectStandardInput = true;
si.RedirectStandardOutput = true;
si.UseShellExecute = false;
// Start the procses.
Process p = Process.Start(si);
p.StandardInput.WriteLine("iisreset","/restart");
p.StandardInput.WriteLine("exit");
// Read all the output generated from it.
string output = p.StandardOutput.ReadToEnd();
StreamWriter writer = new StreamWriter(alertLog, true, Encoding.UTF8);
writer.WriteLine(DateTime.Now + ": \"" + output);
writer.Close();
The code work in Windows 2000 server, the output is
Attempting stop...
Internet services successfully stopped
Attempting start...
Internet services successfully restarted
but when I run the code in Windows 2003 Enterprise Edition, the iisreset
don't work and I get
1/12/2005 3:33:24 PM: "Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
c:\windows\system32\inetsrv>iisreset
Access denied, you must be an administrator of the remote computer to use
this
command. Either have your account added to the administrator local group of
the remote computer or to the domain administrator global group.
c:\windows\system32\inetsrv>exit
Do anyone know how to solve this?