【发布时间】:2015-04-14 15:57:14
【问题描述】:
我目前正在尝试查看是否可以在我的经典 ASP 页面中使用ServiceController,以便该页面可以将自定义命令发送到我的 Windows 服务。我在网上阅读的所有文章和问题都是关于使用 ASP.NET 或其他应用程序/组件的(但遗憾的是,我仅限于使用 Classic ASP)。我的两次尝试都失败了,因为我收到了这个错误:
Microsoft VBScript compilation error '800a0401' Expected end of statement
这是我尝试在我的 asp 页面上使用ServiceController 的两次尝试:
尝试 #1 预期的语句结尾指向 '('
Dim myService
Set myService = New ServiceController("MyNewService")
myService.ExecuteCommand(0)
myService.ExecuteCommand(1)
myService.ExecuteCommand(2)
尝试 #2 预期的语句结尾指向“As”
Dim myService As New ServiceController("MyNewService")
myService.ExecuteCommand(0)
myService.ExecuteCommand(1)
myService.ExecuteCommand(2)
那么,可以在 Classic ASP 中使用 ServiceController 吗?请解释它如何可能或为什么不可能。
【问题讨论】:
-
你确定
ServiceController被识别了吗?您是否包含了Class定义? -
VBScript不支持带参数的构造函数。你试过Set myService = New ServiceController吗? -
@haim770 是的,
ServiceController类没有定义,但亚历克斯的回答解释了原因。不过感谢您的帮助! -
他要求 1) 链接或 2) 为我工作。两者都非常离题。再次,转到元。讨论。
标签: .net vbscript asp-classic servicecontroller