Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从VB6到.net服务的ExecuteCommand_.net_Shell_Vb6_Windows Services - Fatal编程技术网

从VB6到.net服务的ExecuteCommand

从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)

在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)  
是否也可以执行从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编写)应该检查是否有任何工具正在运行。