欢迎来到入门教程网!

vb

当前位置:主页 > 软件编程 > vb >

WMI 创建系统服务的实现代码(Automatic)

来源:本站原创|时间:2020-01-10|栏目:vb|点击:

复制代码 代码如下:

Const OWN_PROCESS = &H10
Const ERR_CONTROL = &H2
Const INTERACTIVE = False

ServiceName = "TestService"
DisplayName = "This is a test service."
InstallPath = "c:\windows\system32\Test.exe"

Set ObjWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate, (Security)}!\\.\root\cimv2")

Set ObjSvr = ObjWMI.Get("Win32_Service")
Return = ObjSvr.Create(ServiceName, DisplayName, InstallPath, OWN_PROCESS, ERR_CONTROL, "Automatic", INTERACTIVE, "LocalSystem", "")
If (Return = 0) Then
 Wscript.Echo "Service create success."
 Wscript.Echo "ServiceName: " & ServiceName
 Wscript.Echo "DisplayName: " & DisplayName
 Wscript.Echo "InstallPath: " & InstallPath
 Wscript.Echo ""
Else
 Wscript.Echo "Service create failure(" & Return & ")."
 Wscript.Quit(Return)
End If
Wscript.Quit

上一篇:使用VBS修改二进制文件HEX数据

栏    目:vb

下一篇:VBS监视网络连接与断开的代码

本文标题:WMI 创建系统服务的实现代码(Automatic)

本文地址:https://www.xiuzhanwang.com/a1/vb/7318.html

网页制作CMS教程网络编程软件编程脚本语言数据库服务器

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:835971066 | 邮箱:835971066#qq.com(#换成@)

Copyright © 2002-2020 脚本教程网 版权所有