The last puzzle piece of my most recent project has been a tricky one, starting and stopping the squid service (it is a proxy server). The reason I need this is to refresh the list of blocked sites.
Here is the code I am using:
vb
'Try
Dim squidService As New System.ServiceProcess.ServiceController("Squid")
If squidService.Status = ServiceProcess.ServiceControllerStatus.Running Then
' Problem Occurs Here.
squidService.Stop()
End If
squidService.WaitForStatus(ServiceProcess.ServiceControllerStatus.Stopped)
squidService.Start()
squidService.WaitForStatus(ServiceProcess.ServiceControllerStatus.Running)
'Catch ex As Exception
'lblInfo.Text = "An error occurred while attempting to restart squid: " + ex.Message
'End Try
The exception handling has been commented out so I could get detailed exception information. The problem occurs when I try to stop the squid service, the error given is "Access is denied". I am using IIS 7, and have tried a handful of ways to try and set my application to run as a domain administrator (Application Pools), to no avail.
I have tried other methods such as invoking taskkill.exe, creating an external console application and calling it to do the work via the ASP.NET (which does the job without being called by ASP.NET), all to no avail. The Web Application has been given full trust.
Does anybody have any ideas as to what could be up with this? I have a hunch that it's got something to do with User Permissions, but don't know enough about IIS to set them (which I have attempted and failed).
Any assistance would be greatly appreciated. Attached is an image of what the exception looks like via web debugging. Thanks in advance
