forum.vlekkem.org http://forum.vlekkem.org/ |
|
Microsoft efficiency! http://forum.vlekkem.org/viewtopic.php?f=1&t=401 |
Page 1 of 1 |
Author: | tbone [ Thu Feb 26, 2009 7:20 pm ] |
Post subject: | Microsoft efficiency! |
'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 |
Author: | tbone [ Thu Feb 26, 2009 7:37 pm ] |
Post subject: | Re: Microsoft efficiency! |
ge zodj zelfs kennen alle lentjes en spaces wegdoen uk ten eje Code: on error resume next Dim fso, WshShell, WshNetwork, WshSysEnv Set WshShell = Wscript.CreateObject("Wscript.Shell") 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 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 iet kerter mor ik weet niet of dat het on de leesbaarheid iet goed doet |
Page 1 of 1 | All times are UTC + 2 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |