Solved

Need help in writting a script to stop a service

Posted on 2008-10-26
4
428 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
Comment Utility
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
Comment Utility
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
Comment Utility
Lawot, can we please get an update.
0

Featured Post

Why do Marketing keep bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

Join & Write a Comment

Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we show how to create an Address List 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 Organization >> Ad…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now