I am trying to write a script to shutdown a specific service on a Win2K3
server. My script (copied from a TechNet article) is as follows:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & _
"\root\cimv2")

Set objService = _
objWMIService.Get("Win32_Service.Name='SyndMailBBSvc'")

Return = objSyndMailBounceBack.StopService()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

When I run the script I get the following error:

swbemservicesEX Not Found

Can anyone tell me where this error is coming from? I can't find much in
the various groups.

Thanks,
Joe

Re: SwbemservicesEX Not Found by Pegasus

Pegasus
Wed Mar 05 10:31:58 CST 2008


"Joe" <Joe@discussions.microsoft.com> wrote in message
news:8049C83D-69EB-4440-B0E0-84082A23FC40@microsoft.com...
>I am trying to write a script to shutdown a specific service on a Win2K3
> server. My script (copied from a TechNet article) is as follows:
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & _
> "\root\cimv2")
>
> Set objService = _
> objWMIService.Get("Win32_Service.Name='SyndMailBBSvc'")
>
> Return = objSyndMailBounceBack.StopService()
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> When I run the script I get the following error:
>
> swbemservicesEX Not Found
>
> Can anyone tell me where this error is coming from? I can't find much in
> the various groups.
>
> Thanks,
> Joe

I suggest you try the WMS method used in this Scripting Guy article:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb06/hey0227.mspx
Start with the name of a non-essential service (e.g. "Windows Time"),
then move on to your own service.



RE: SwbemservicesEX Not Found by urkec

urkec
Wed Mar 05 13:20:02 CST 2008

"Joe" wrote:

> I am trying to write a script to shutdown a specific service on a Win2K3
> server. My script (copied from a TechNet article) is as follows:
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & _
> "\root\cimv2")
>
> Set objService = _
> objWMIService.Get("Win32_Service.Name='SyndMailBBSvc'")
>
> Return = objSyndMailBounceBack.StopService()
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> When I run the script I get the following error:
>
> swbemservicesEX Not Found
>
> Can anyone tell me where this error is coming from? I can't find much in
> the various groups.
>
> Thanks,
> Joe

It looks like you misspelled the name of the service. Get the exact name:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & _
"\root\cimv2")

Set colServices = objWMIService.ExecQuery _
("Select * From Win32_Service")

For Each objService In colServices
WScript.Echo objService.Name
Next

Then you can use it with objWMIService.Get

--
urkec

RE: SwbemservicesEX Not Found by Joe

Joe
Thu Mar 06 10:51:01 CST 2008

I copied the name out of the services window, but I will run your routine to
confirm.

Thanks,
Joe

"urkec" wrote:

> "Joe" wrote:
>
> > I am trying to write a script to shutdown a specific service on a Win2K3
> > server. My script (copied from a TechNet article) is as follows:
> >
> > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" & strComputer & _
> > "\root\cimv2")
> >
> > Set objService = _
> > objWMIService.Get("Win32_Service.Name='SyndMailBBSvc'")
> >
> > Return = objSyndMailBounceBack.StopService()
> > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> >
> > When I run the script I get the following error:
> >
> > swbemservicesEX Not Found
> >
> > Can anyone tell me where this error is coming from? I can't find much in
> > the various groups.
> >
> > Thanks,
> > Joe
>
> It looks like you misspelled the name of the service. Get the exact name:
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & _
> "\root\cimv2")
>
> Set colServices = objWMIService.ExecQuery _
> ("Select * From Win32_Service")
>
> For Each objService In colServices
> WScript.Echo objService.Name
> Next
>
> Then you can use it with objWMIService.Get
>
> --
> urkec

Re: SwbemservicesEX Not Found by Joe

Joe
Thu Mar 06 10:58:05 CST 2008

Thanks much! I'll test this next week and see where I get.

Thanks,
Joe

"Pegasus (MVP)" wrote:

>
> "Joe" <Joe@discussions.microsoft.com> wrote in message
> news:8049C83D-69EB-4440-B0E0-84082A23FC40@microsoft.com...
> >I am trying to write a script to shutdown a specific service on a Win2K3
> > server. My script (copied from a TechNet article) is as follows:
> >
> > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" & strComputer & _
> > "\root\cimv2")
> >
> > Set objService = _
> > objWMIService.Get("Win32_Service.Name='SyndMailBBSvc'")
> >
> > Return = objSyndMailBounceBack.StopService()
> > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> >
> > When I run the script I get the following error:
> >
> > swbemservicesEX Not Found
> >
> > Can anyone tell me where this error is coming from? I can't find much in
> > the various groups.
> >
> > Thanks,
> > Joe
>
> I suggest you try the WMS method used in this Scripting Guy article:
> http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb06/hey0227.mspx
> Start with the name of a non-essential service (e.g. "Windows Time"),
> then move on to your own service.
>
>
>