I have created a windows service that checks a database for errors and if a specific one shows up I want it to perform an IISRESET
command.
The problem is, if I run and IISRESET command without the elevated privileges then it won't actually do the reset. So I have my code doing all I want, but I'm not sure if the IISRESET
command is being run as an administrator and I don't know how to verify that.
Here is the code I have
ErrorCheckerEventLog.WriteEntry("Performing IISReset", EventLogEntryType.Warning);
Process process = new Process();
process.StartInfo.Verb = "runas";
process.StartInfo.FileName = "iisreset.exe";
process.StartInfo.UseShellExecute = true;
process.StartInfo.CreateNoWindow = false;
process.StartInfo.RedirectStandardError = false;
process.StartInfo.RedirectStandardOutput = false;
process.Start();
process.WaitForExit();
ErrorCheckerEventLog.WriteEntry("IISReset finished", EventLogEntryType.Information);
In the Application event log I get these:
Listener Adapter protocol 'net.tcp' successfully connected to Windows Process Activation Service.
Listener Adapter protocol 'net.pipe' successfully connected to Windows Process Activation Service.
In the system event log I get these:
IIS start command received from user testing\neil.kenny. The logged data is the status code.
It all looks good to me, but I'm still not sure it actually did the reset. It could have just ran the iisreset command which then output the access denied message.
How do I properly verify this?