Solved

Need help in writting a script to stop a service

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

730 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