当前位置: 移动技术网 > IT编程>脚本编程>VBScript > WMI 创建系统服务的实现代码(Automatic)

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

2017年12月08日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:const own_process = &h10const err_control = &h2const interactive = false se

复制代码 代码如下:

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

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网