It is currently Fri Mar 29, 2024 7:55 am




Post new topic Reply to topic  [ 2 posts ] 
 Microsoft efficiency! 
Author Message
l33t p0wahz
User avatar

Joined: Wed Oct 29, 2003 4:40 pm
Posts: 1966
Location: Küssen Zie bitte mein Esel
Post 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

_________________
Carve hard! ... or die trying


Thu Feb 26, 2009 7:20 pm
Profile
l33t p0wahz
User avatar

Joined: Wed Oct 29, 2003 4:40 pm
Posts: 1966
Location: Küssen Zie bitte mein Esel
Post 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 :)

_________________
Carve hard! ... or die trying


Thu Feb 26, 2009 7:37 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.