WMI如何创建系统服务-创新互联

这篇文章主要介绍WMI如何创建系统服务,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

创新互联建站主营三穗网站建设的网络公司,主营网站建设方案,成都APP应用开发,三穗h5微信小程序开发搭建,三穗网站营销推广欢迎三穗等地区企业咨询

代码如下:


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


以上是“WMI如何创建系统服务”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


文章题目:WMI如何创建系统服务-创新互联
本文来源:http://myzitong.com/article/cophhh.html