サービス一覧

  ADSI -- usage : cscript Service.vbs machine user password



Service.vbs
  
Set Argv = WScript.Arguments

on error resume next
if Argv.Count <> 0 then
	Set objNspace = GetObject("WinNT:")
	Set objAdsi = objNspace.OpenDSObject( _
		"WinNT://" & Argv(0), Argv(1), Argv(2), &H1 )
	if Err.Number <> 0 then
		Wscript.Echo Err.Description
		Wscript.Quit
	end if
else
	Set objAdsi = GetObject("WinNT://.")
end if
on error goto 0

objAdsi.Filter = Array("Service")

strList = ""
For Each obj in objAdsi
	Select case obj.Status
		Case 4
			strList = strList & "実行    "
		Case 1
			strList = strList & " --     "
		Case Else
			strList = strList & "その他  "
	End Select
	strList = strList & obj.Name & vbCrLf
Next

Wscript.Echo strList
  



  WMI -- usage : cscript Service.vbs machine user password (ローカル接続は引数無し)



Service2.vbs
  
Set Argv = WScript.Arguments

if Argv.Count <> 0 then
	strServer = Argv(0)
	strUser = Argv(1)
	strPass = Argv(2)
else
	strServer = "."
end if

on error resume next
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
if Err.Number <> 0 then
	Wscript.Echo Err.Description
	Wscript.Quit
end if

Set objWmi = objLocator.ConnectServer( _
	strServer, _
	"root\cimv2", _
	strUser, _
	strPass )
if Err.Number <> 0 then
	Wscript.Echo Err.Description
	Wscript.Quit
end if

objWmi.Security_.ImpersonationLevel = 3
if Err.Number <> 0 then
	Wscript.Echo Err.Description
	Wscript.Quit
end if
on error goto 0

Set objTarget = objWmi.ExecQuery( "select Name,Started,PathName from Win32_Service" )

strList = ""
on error resume next
For Each obj in objTarget

	if obj.Started then
		strList = strList & "実行    "
	else
		strList = strList & " --     "
	end if
	strList = strList & obj.Name & vbCrLf
'	strList = strList & obj.PathName & vbCrLf

Next
on error goto 0

Wscript.Echo strList
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加




SQLの窓  天気  IT用語辞典
Yahoo!ニュース  マルチ辞書
PHP マニュアル  Google URL短縮 


フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ