天下网吧 >> 网吧天地 >> 网吧技术 >> 网吧软件 >> 正文

停止和开启服务的vbs脚本

2010-7-9未知佚名

停止和开启服务的vbs脚本

以下为开启的代码

' Copyright (c)  Microsoft Corporation, All Rights Reserved
'***************************************************************************
'
' WMI Sample Script - Starts a service (VBScript)
'
' This script demonstrates how to start a specific service from instances of
' Win32_Service.
'
' NOTE:  This script only applies to NT-based systems since Win9x does support services
'
'
'***************************************************************************
Set ServiceSet = GetObject("winmgmts:").ExecQuery("select * from Win32_Service where Name='ClipSrv'")

for each Service in ServiceSet
 RetVal = Service.StartService()
 if RetVal = 0 then WScript.Echo "Service started"
 if RetVal = 10 then WScript.Echo "Service already running"
next
 

以下为停止的代码:

' Copyright (c)  Microsoft Corporation, All Rights Reserved
'***************************************************************************
'
' WMI Sample Script - Stops a service (VBScript)
'
' This script demonstrates how to stop a specific service from instances of
' Win32_Service.
'
' NOTE:  This script only applies to NT-based systems since Win9x does support services
'
'
'***************************************************************************
Set ServiceSet = GetObject("winmgmts:").ExecQuery("select * from Win32_Service where Name='ClipSrv'")

for each Service in ServiceSet
 RetVal = Service.StopService()
 if RetVal = 0 then
  WScript.Echo "Service stopped"
 elseif RetVal = 5 then
  WScript.Echo "Service already stopped"
 end if
next
 

本文来源:未知 作者:佚名

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。文章是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。 Email:support@txwb.com,系统开号,技术支持,服务联系微信:_WX_1_本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧·网吧天下
  • 本周热门
  • 本月热门
  • 阅读排行