Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


start a windows service, using vbs

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> start a windows service, using vbs
  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 a windows service, using vbs - 12/29/2006 7:38:41 AM   
  netman06

 

Posts: 108
Score: 0
Joined: 10/19/2006
Status: offline
Hello,

where can I find information on how to enable a disabled windows service.

Thanks,

Mike

I found this but it has some errors.

Option Explicit
' ------ SCRIPT CONFIGURATION ------
Dim strComputer : strComputer = "."
Dim strSvcName : strSvcName = "Alerter"
' ------ END CONFIGURATION ---------
Dim objWMI : set objWMI = GetObject("winmgmts:\\" & strComputer & _
"\root\cimv2")
Dim objService: set objService = objWMI.Get("Win32_Service.Name='" & _
strSvcName & "'")
WScript.Echo "Restarting " & objService.Name & "..."
RecursiveServiceStop objService
RecursiveServiceStart objService
WScript.Echo "Successfully restarted service"
Function RecursiveServiceStop ( objSvc )
Dim colServices : set colServices = objWMI.ExecQuery("Associators of " _
& "{Win32_Service.Name='" & objSvc.Name & "'} Where " _
& "AssocClass=Win32_DependentService Role=Antecedent" )
Dim objS
for each objS in colServices
RecursiveServiceStop objS
next
Dim intRC : intRC = objSvc.StopService
if intRC > 0 then
WScript.Echo " Error stopping service: " & objSvc.Name
WScript.Quit
else
WScript.Echo " Successfully stopped service: " & objSvc.Name
end if
End Function
Function RecursiveServiceStart ( objSvc )
Dim intRC : intRC = objSvc.StartService
if intRC > 0 then
WScript.Echo " Error starting service: " & objSvc.Name
WScript.Quit
else
WScript.Echo " Successfully started service: " & objSvc.Name
end if
Dim colServices : set colServices = objWMI.ExecQuery("Associators of " _
& "{Win32_Service.Name='" & objSvc.Name & "'} Where " _
& "AssocClass=Win32_DependentService Role=Antecedent" )
Dim objS
for each objS in colServices
RecursiveServiceStart objS
next
End Function

 
 
Post #: 1
 
 RE: start a windows service, using vbs - 12/29/2006 8:08:09 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
What error are you receiving? The following will show you a simple way to query a service.  If you want to stop, start, pause, resume, changestartmode, then look at the methods for Win32_Service class.  http://msdn2.microsoft.com/en-gb/library/aa394418.aspx


      

_____________________________

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 netman06)
 
 
Post #: 2
 
 RE: start a windows service, using vbs - 12/29/2006 8:25:54 AM   
  netman06

 

Posts: 108
Score: 0
Joined: 10/19/2006
Status: offline
I looked at the web link. but it did not explain how to enable a disabled service.

this seems to me like a very common task, so if anyone can give a another example.

Thanks, for the posts.

Mike

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: start a windows service, using vbs - 12/29/2006 8:28:02 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
In the for each you would use something like objItem.ChangeStartMode("Manual") or Automatic or any of the other option you can find by clicking on the link under methods labeled ChangeStartMode found on the link provided.

_____________________________

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 netman06)
 
 
Post #: 4
 
 RE: start a windows service, using vbs - 12/29/2006 9:00:40 AM   
  netman06

 

Posts: 108
Score: 0
Joined: 10/19/2006
Status: offline
I think that changing the startmode, does not start the service, if it has been disabled?

I want to start a windows service, that by default is set to disabled. the Messenger service.

I know I might have to run it as a RunAs, which can still work for me.


Thanks,

Mike

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: start a windows service, using vbs - 12/29/2006 9:13:29 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
then simply do objItem.StartService
Play around with the example provided and the various methods and properties available which are all described in the link for Win32_Service

_____________________________

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 netman06)
 
 
Post #: 6
 
 RE: start a windows service, using vbs - 12/30/2006 1:32:21 AM   
  netman06

 

Posts: 108
Score: 0
Joined: 10/19/2006
Status: offline
I researched starting a stopped service, and it seems like this will work, but my problem is the services is disabled by default.

It seem logical to have these services disabled for spammers and hackers. but in my situation I have a administrator account and password.

So has anybody ever tried doing this before, starting a disabled windows service.

Thanks,

Mike

(in reply to dm_4ever)
 
 
Post #: 7
 
 RE: start a windows service, using vbs - 12/30/2006 3:12:34 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
I do believe everything needed has been covered.

If the service is disabled, then change its start mode so it is no longer disabled.  Then, you start the service.  I know this can be done.  How about posting what you have or have tried?

< Message edited by dm_4ever -- 12/30/2006 5:15:06 AM >


_____________________________

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 netman06)
 
 
Post #: 8
 
 RE: start a windows service, using vbs - 1/2/2007 12:09:21 AM   
  mbouchard


Posts: 1922
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Take a look at sc.exe  It is on WinXP/Vista by deafult and can be copied to 2000 as needed (use the XP version) you can start, stop, query, set persistant status etc.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to dm_4ever)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> start a windows service, using vbs 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