sc.Pause() throws an exception

50 Views Asked by At
            sc.Pause()
            Try
                While sc.Status = ServiceControllerStatus.Paused
                    Threading.Thread.Sleep(1000)
                    sc.Refresh()
                End While
            Catch ex As Exception

            End Try

Hello everyone!

I am having an issue with the above code. when sc.Pause() runs it gives me an exception of

'Cannot open Dhcp Service on computer '.' inner Exception Win32Exception: Access is denied

Any help is appreciated!

Thanks,

Kyvex

1

There are 1 best solutions below

6
AudioBubble On

I figured out one piece of the puzzle. I changed the app.manifest file to run in

highestAvailable

Now it throws an exception of

'Cannot pause Dhcp service on computer '.' Inner Exception Win32Exception: The request control is not valid for this service