从VB6到.net服务的ExecuteCommand
在VB.net中,我可以在Windows服务上执行自定义命令: 桌面:从VB6到.net服务的ExecuteCommand,.net,shell,vb6,windows-services,.net,Shell,Vb6,Windows Services,在VB.net中,我可以在Windows服务上执行自定义命令: 桌面: Const SmartShutdown As Integer = 12 Dim myService As New ServiceController("SampleService") myService.ExecuteCommand(SmartShutdown) Windows服务: Protected Overrides Sub OnCustomCommand(ByVal command As Integer)
Const SmartShutdown As Integer = 12
Dim myService As New ServiceController("SampleService")
myService.ExecuteCommand(SmartShutdown)
Windows服务:
Protected Overrides Sub OnCustomCommand(ByVal command As Integer)
是否也可以执行从VB6到.net Windows服务的命令?考虑使用VB6功能和sc.exe
命令行工具来控制Windows服务,例如:
Shell("cmd /C 'sc stop SampleService > %APPDATA%\svc.log'")
更新
要发送自定义命令,例如:
Shell("cmd /C 'sc control SampleService 128 > %APPDATA%\svc.log'")
自定义命令应在128-255范围内。您可以使用API函数发送任何控制代码。
这确实需要您已使用适当的访问权限调用,并且您的进程正在所需的级别上运行。
在Vista+上,这可以使用普通清单(进程范围)或。是否还有执行自定义命令的方法?我的服务使用共享dll管理工具。当我安装主程序的新版本时,我的安装程序(用vb6编写)应该检查是否有任何工具正在运行。