Solved

Wildcard Services restart

Posted on 2011-03-24
5
2,054 Views
Last Modified: 2012-05-11
We have a server which runs multiple TOMCAT services.

The services are registered with a naming comvention --> SERVICE<PRACTICEName>

Currently, we have setup a .BAT file which lists all services to start / stop them...
eg.
net start SERVICEABC
net start SERVICEPLANT

net stop SERVICEABC
net stop SERVICEPLANT


We add new services all the time and the list grows and is difficult to maintain the batch file.

Is it possible to use a WILDCARD like 'net start SERVICE*' or something?
0
Comment
Question by:nainil
[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
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:dan_blagut
ID: 35213265
Hello

if your services have one dependency in commun, normally when you restart that dependency service, all will be restarted. If not I will bet on a vbscript that pick the service name from a text file then restart it.

Dan
0
 

Author Comment

by:nainil
ID: 35213744
currently we mailtain a batch file whicl already lists all services. but we would like to move away from the same.

it is difficult to maintain the batch file with new services whick are added regularly.
0
 
LVL 22

Accepted Solution

by:
dan_blagut earned 250 total points
ID: 35213796
Then you can use something like that :

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
    ("Select * from win32_Service")
For each objService in colServices
    If left(objService.Name,7) = "Service_" Then
       objService.StopService()
       objService.StartService()
     End If
Next

In example the service name must begin with "Service_" (case sensitive).

Dan
0
 

Author Comment

by:nainil
ID: 35223651
Quick Question Dan_blaqut...

Is this something which I can use in a .bat file?

Or something else? how can one execute the same?
0
 

Author Comment

by:nainil
ID: 35224188
I figured it out :). used cscript "services.vbs" (which has the code).

Thank you dan_blagut for your time and efforts.

-Nainil C
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

#Citrix #POC #XenDesktop #vCenter #VMware #ESX
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

739 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