'With windows you can do more in less time, it works more intuitive than any version before, ... etc"
Windows script voor process check / restart te doen :
(met dank aan de schrijver vossenn die der uk ni kan on doen
)
Code:
‘----begin vbs----------
on error resume next
'--------------------------------------------------------------------------------------------------------------
' Declarations
'--------------------------------------------------------------------------------------------------------------
Dim fso, WshShell, WshNetwork, WshSysEnv
'--------------------------------------------------------------------------------------------------------------
' Create objects
'--------------------------------------------------------------------------------------------------------------
Set WshShell = Wscript.CreateObject("Wscript.Shell")
'--------------------------------------------------------------------------------------------------------------
' Constants and Variables
'--------------------------------------------------------------------------------------------------------------
sComputerName = WshShell.RegRead("HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName")
sComspec = WshSysEnv("Comspec")
If sComspec = "" Then sComspec = WshShell.ExpandEnvironmentStrings ("%ComSpec%")
If sComspec = "" Then sComspec = sWindir & "\System32\cmd.exe"
' ****************************************************************************
Function IsProcessRunning( strServer, strProcess )
Dim Process, strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
IsProcessRunning = True
Exit Function
End If
Next
End Function
' ****************************************************************************
' Main
' ****************************************************************************
Dim strProcess
strProcess = "logonserver.exe"
If( IsProcessRunning( sComputerName, strProcess ) = False ) Then
'WScript.Echo "Process " & strProcess & " is NOT running on computer " & strComputer
wshshell.run "cmd /c " & chr(34) & "C:\logonserver.bat" & Chr(34),1,False
End If
‘------ end vbs
hier het unix equivalent :
Code:
ps -ef | grep logonserver
if [ "$?" -gt 0 ] ; then
/usr/bin/logonserver &
fi