?
Solved

Need help in writting a script to stop a service

Posted on 2008-10-26
4
Medium Priority
?
441 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 1000 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 1000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

770 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