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
Solved

Need help in writting a script to stop a service

Posted on 2008-10-26
4
438 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

839 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