Loading
Scriptbox
 VBScript Links 
 About VBscript 
 JavaScript Links 
 About JavaScript 
 Powershell Links 
 PSCRIPT the Script Launcher 
 PowerShell Shortcut Keys 
 About Powershell 
     VBScript
    JavaScript
    Powershell
Disclaimer
Contact
Latest 10 Scripts
Script search
  :: { Category } :: 0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ
         

Search Options:  Start  a  Service  

 Content of Start a Service.vbs
MD5 Hash: B210A2519244053F6E667AD846E13418

Msgbox StartService("Alerter")

' --------------------------------------- - Start a Service -
Private Function StartService(strService)

On Error Resume Next

Dim oWshShell : Set oWshShell = CreateObject("WScript.Shell")

Dim oService, iTimeOut, strComputername, tt
strComputername = oWshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
iTimeOut = 60

Set oService = GetObject("WinNT://" & strComputername & "/" & strService)

If (Not oService.status = 4) Then
oService.Start
wscript.sleep(250)

For tt = 0 to iTimeOut
If (oService.status = 4) Then
Exit For
Else
wscript.sleep(1000)
End If
Next
End if

If (IsObject(oService)) Then Set oService = Nothing
If (IsObject(oWshShell)) Then Set oWshShell = Nothing

If ( Err.Number <> 0 ) Then
StartService = "ERROR: " & Err.Number & " " & Err.Description
Err.Clear
Else
StartService = strService & " started successful"
End If

End Function

   © 2008 - 2013 Boris Toll      :: Scripts available: 6.481 ::      :: scriptbox.toll.at ::      :: powered by www.toll.at ::
  Google Entries:n/a
  Yahoo Backlinks:n/a
  Live Backlinks:n/a
  del.icio.us Bookmarks:n/a
  Technorati Links:n/a