0
            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 Answers1

0

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
  • Try running the app as admin after building it, if it works go to ur project properties, view windows settings, and change asInvoker to requireAdministrator – OctaCode Apr 02 '19 at 22:21
  • Can you pause the DHCP service manually? Just to check it is possible. – Andrew Morton Apr 03 '19 at 08:10
  • @AndrewMorton Yeah that is where I got stumped you can't Pause it unfortunately. So I am going to have to try to work around it but I do not know how possible that is. –  Apr 03 '19 at 13:15
  • You can stop the service and then start it. It may not be fast at starting compared to what you might expected for unpausing. – Andrew Morton Apr 03 '19 at 13:21
  • @AndrewMorton Unfortunately that won't work. There are a few services that depend on the DHCP service so if I stop the service then those others ones will stop. So not only will I have to start the DHCP service I'll have to start the others as well. –  Apr 03 '19 at 13:37
  • Perhaps if you updated the question to explain what you want to achieve by pausing the DHCP service, someone would be able to help. – Andrew Morton Apr 03 '19 at 20:04