I'm currently trying to see if I can use ServiceController
in my Classic ASP page so that the page can send custom commands to my Windows Service. All the articles and questions I have read online were about using ASP.NET or another application/component (but sadly I'm limited to only using Classic ASP). Both of my attempts failed because I get this error:
Microsoft VBScript compilation error '800a0401' Expected end of statement
Here are my two attempts at trying to use ServiceController
on my asp page:
Attempt #1 Expected end of statement points to '('
Dim myService
Set myService = New ServiceController("MyNewService")
myService.ExecuteCommand(0)
myService.ExecuteCommand(1)
myService.ExecuteCommand(2)
Attempt #2 Expected end of statement points to 'As'
Dim myService As New ServiceController("MyNewService")
myService.ExecuteCommand(0)
myService.ExecuteCommand(1)
myService.ExecuteCommand(2)
So, is it possible to use ServiceController in Classic ASP? Please explain how it is possible or why it is not possible.
ServiceController
is a .Net class, VBScript has no idea what it is.
Given that its also not exposed via COM it cannot be used from within VBScript.
Create a .Net COM Visible assembly that wraps the calls to a ServiceController
, instantiate it in VBScript (Server.CreateObject()
) and call methods you have implemented in C#/VB.Net that do what you need.