Solved

Need help in writting a script to stop a service

Posted on 2008-10-26
4
440 Views
Last Modified: 2009-06-15
I have a service on  a windows 2003 machine.

The Service Name is Amicus PE Service

The Display Name is Amicus PE Service


The Path to executable is : C:\Amicus\Amicus Attorney PE Server\SmartClient\Server\AmicusAttorney.XOL.ServerService.exe


I want to write a script that stops this service and restarts it.  

I have been trying

Net Stop Amicus PE Service and that does not work.  Any ideals?


0
Comment
Question by:Lawot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 250 total points
ID: 22807835
Have you tried enclosing the service name in double quotes (like: "Amicus PE Service") when using NET STOP?

Kind regards,

Matthias Vance
0
 
LVL 24

Assisted Solution

by:andrew_aj1
andrew_aj1 earned 250 total points
ID: 22808115
I quickly made a vbs script that will do exactly what you need. It will stop the service, wait 15 seconds, and then restart it. You can modify it if you need.
Make sure you save the file as a .vbs extension.
I got information on how to do this from:
http://www.computerperformance.co.uk/vbscript/wmi_services.htm
I hope this helps. Good luck.


Option Explicit
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService, intSleep 
strComputer = "."
intSleep = 15000
 
'On Error Resume Next
' NB strService is case sensitive.
strService = " 'Amicus PE Service' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")
For Each objService in colListOfServices
objService.StopService()
WSCript.Sleep intSleep
objService.StartService()
Next 

Open in new window

0
 
LVL 24

Expert Comment

by:andrew_aj1
ID: 23244049
Lawot, can we please get an update.
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In-place Upgrading Dirsync to Azure AD Connect
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
how to add IIS SMTP to handle application/Scanner relays into office 365.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question