Jump to content

Stop a service require an answer


Recommended Posts

  • Moderators

@Valnurat you can use WMI to stop/start the service. I would suggest searching the forum for ScriptOMatic. Here is an example snippet you should be able to modify to your needs:

#RequireAdmin
#include <MsgBoxConstants.au3>

$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$oServiceList = $oWMI.ExecQuery("Select * from Win32_Service where DisplayName='Windows Search'")

For $sService in $oServiceList
    MsgBox($MB_OK, "", $sService.Name)
    $sService.StopService()
Next

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thank you for the hint.

I tried it, but the service will not stop.

 

#RequireAdmin
#include <MsgBoxConstants.au3>

$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$oServiceList = $oWMI.ExecQuery("Select * from Win32_Service where DisplayName='Windows Management Instrumentation'")

For $sService in $oServiceList
;    MsgBox($MB_OK, "", $sService.Name)
    $sService.StopService()
Next

 

Yours sincerely

Kenneth.

Link to comment
Share on other sites

39 minutes ago, Valnurat said:

:>

I'm sorry for being stupid, but then I don't know how.

What Logan means is that you tried to stop the WMI service in your example , using WMI :) . Try with WMI to stop another service and it should work.

Link to comment
Share on other sites

If we have problems with SCCM we has a procedure to stop WMI.

We can't delete C:\Windows\system32\wbem\Repository because it is locked.

Services as "SMS Agent Host" are depending of WMI. I think SMS Agent Host is locking the folder we should delete.

Yours sincerely

Kenneth.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...