Reputation: 701
How to start windows service through VB Script?
I tried following code to start Mysql service
test.vbs:
service="MySQL55"
Set wmi = GetObject("winmgmts://./root/cimv2")
qry = "SELECT * FROM Win32_Service WHERE Name='" & service & "'"
For Each s In wmi.ExecQuery(qry)
s.StartService
Next
But this code not starts the mysql service.
Upvotes: 1
Views: 3580
Reputation: 200233
Assuming that the service is actually named "MySQL55" check the return value of StartService
:
For Each s In wmi.ExecQuery(qry)
rc = s.StartService
WScript.Echo s.Name & ": " & rc
Next
Upvotes: 2