Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Management
- Imports System.ServiceProcess
- Public Class StartAndStop
- Dim wmic As ManagementObjectCollection
- Private Sub StartAndStop()
- ' * osppsvc
- ' - Start / Stop
- Dim x As New ServiceController("Office Software Protection Platform")
- If x.Status.Equals(ServiceControllerStatus.Stopped) Or x.Status.Equals(ServiceControllerStatus.StopPending) Then
- x.Start()
- Else
- x.Stop()
- End If
- ' - Enable / Disable
- wmic = New ManagementObjectSearcher("SELECT Name, StartMode FROM Win32_Service WHERE Name LIKE '%osppsvc%'").Get()
- For Each wm As ManagementObject In wmic
- If wm.GetPropertyValue("StartMode") = "Disabled" Then
- wm.InvokeMethod("ChangeStartMode", {"Automatic"})
- Else
- wm.InvokeMethod("ChangeStartMode", {"Disabled"})
- End If
- Next
- ' * sppsvc
- ' - Start / Stop
- Dim y As New ServiceController("Software Protection")
- If y.Status.Equals(ServiceControllerStatus.Stopped) Or y.Status.Equals(ServiceControllerStatus.StopPending) Then
- y.Start()
- Else
- y.Stop()
- End If
- ' - Enable / Disable
- wmic = New ManagementObjectSearcher("SELECT Name, StartMode FROM Win32_Service WHERE Name LIKE '%sppsvc%'").Get()
- For Each wm As ManagementObject In wmic
- If wm.GetPropertyValue("StartMode") = "Disabled" Then
- wm.InvokeMethod("ChangeStartMode", {"Automatic"})
- Else
- wm.InvokeMethod("ChangeStartMode", {"Disabled"})
- End If
- Next
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement