• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3261
  • Last Modified:

Restart Service via Script?

I need to restart a windows service using vbs script the service name is "Papercut Application Server". Is there any way to do this via vbs script ?
0
dion_p1
Asked:
dion_p1
1 Solution
 
David LeeCommented:
On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
This will start a service.

strComputer = "ComputerName"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName='Papercut Application Server'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
      objItem.StartService
Next
0
 
dion_p1Author Commented:
Is there a way to stop it first?
0
 
StuFox100Commented:
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now