Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Start, Stop, & Restart Services (Incl. dependencies)

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,46455
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Start, Stop, & Restart Services (Incl. dependencies)
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Start, Stop, & Restart Services (Incl. dependencies) - 4/27/2007 5:42:37 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
Needed this for another script at work and couldnt find anything on the web that was complete and self-contained so I wrote this.
I forgot to mention that it checks for the service's state as well to ensure that it has indeed started/stopped

Usage:
service_control ".","IIS Admin","restart"
the arguments are commented in the sub


      

Code liberally borrowed from the scripting center

< Message edited by kirrilian -- 4/28/2007 4:07:18 PM >


_____________________________

Have you searched here ?
VBScript Fundamentals
My Site
 
 
Revisions: 1 | Post #: 1
 
 RE: Start, Stop, & Restart Services (Incl. dependencies) - 5/5/2007 7:56:59 AM   
  dm_4ever


Posts: 2359
Score: 36
Joined: 6/29/2006
From: Orange County, California
Status: offline
I tried this out the other day and it worked great. 

Just a thought...rather than waiting for an error to tell you there are dependent services, why not start off checking for dependent services and starting/stopping them accordingly?  

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to kirrilian)
 
 
Post #: 2
 
 RE: Start, Stop, & Restart Services (Incl. dependencies) - 5/7/2007 3:25:58 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
quote:

ORIGINAL: dm_4ever

I tried this out the other day and it worked great. 

Just a thought...rather than waiting for an error to tell you there are dependent services, why not start off checking for dependent services and starting/stopping them accordingly?  


so that if there arent any, it will go ahead and start the single service

btw, the return code was the fastest/easiest way to tell if there are dependent services

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Start, Stop, & Restart Services (Incl. dependencies) - 1/15/2008 12:45:39 AM   
  kxrain

 

Posts: 1
Score: 0
Joined: 1/15/2008
Status: offline
Just a question you will save this as??

(in reply to kirrilian)
 
 
Post #: 4
 
 RE: Start, Stop, & Restart Services (Incl. dependencies) - 1/15/2008 7:09:06 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
This is a subroutine that is intended to be included in a script that you are writing. It is not intended as a stand alone file.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to kxrain)
 
 
Post #: 5
 
 RE: Start, Stop, & Restart Services (Incl. dependencies) - 1/18/2008 6:20:51 PM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
quote:

ORIGINAL: kxrain

Just a question you will save this as??


You save this as a .vbs file and make sure you insert another line in the beginning like I stated in the Usage

Usage:
service_control ".","IIS Admin","restart"

otherwise the script wont do anything

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to kxrain)
 
 
Post #: 6
 
 RE: Start, Stop, & Restart Services (Incl. dependencies) - 1/21/2008 1:42:25 PM   
  victory73

 

Posts: 31
Score: 0
Joined: 12/3/2007
Status: offline
I modified this script a bit, but it does not work.

It did not return any errors, but did not stop the service.


      

//EDIT 1/22/2008: Added code tags - dm_4ever

< Message edited by dm_4ever -- 1/22/2008 1:17:48 PM >

(in reply to kirrilian)
 
 
Revisions: 1 | Post #: 7
 
 RE: Start, Stop, & Restart Services (Incl. dependencies) - 1/22/2008 1:48:45 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Well if that is your entire script, I don't see anwhere that you actually call the sub.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to victory73)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Start, Stop, & Restart Services (Incl. dependencies) Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts