欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

查看SQL状态的vbs

程序员文章站 2022-06-23 21:04:31
复制代码 代码如下:'**************************** '*by r05e '*检验sql server是否在这机器上工作 '***********...

复制代码 代码如下:

'****************************
'*by r05e
'*检验sql server是否在这机器上工作
'****************************
strcomputer = "."
set objwmiservice = getobject("winmgmts:" _
& "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")
set colservices = objwmiservice.execquery _
("select * from win32_service where name = 'mssqlserver'")
if colservices.count > 0 then
for each objservice in colservices
wscript.echo "sql server is " & objservice.state & "."
next
else
wscript.echo "sql server is not installed on this computer."
end if