Jump to content

Recommended Posts

  • Moderators
Posted

lexus,

Yes, I had already done the conversion in that section. You need to do it in this section:

For $i = 1 To 4
    If $iMsg = $aStop_Start[$i] Then
        RunWait("c:\windows\pstools\pskill  \\" & $aComputer[$i - 1][0] & "  -u user -p password POWERPNT.exe -accepteula") ; <<<<<<<<
        ExitLoop
    EndIf
Next

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted (edited)

No, it isn't.

You create an array with 4 elements. As the index starts with 0 you need to use:
$i = 0 to 3

Edit: Didn't fully read the thread. Ignore what I wrote ;)

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • Moderators
Posted

water,

No, because the button ControlIDs are stored in elements 1 to 4 and it is those that are being checked. I thought it might be easier for a new coder to follow if I did it that way - I should have known better.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

with this code i have the problem

For $i = 1 To 4
    GUICtrlCreateLabel($aComputer[$i - 1][0], 15, (40 * $i), 100, 26)
    GUICtrlSetFont(-1, 14, 400, 0, "Arial")
    $aInput[$i] = GUICtrlCreateInput("Status", 136, (40 * $i), 150, 21)
    $aStop_Start[$i] = GUICtrlCreateButton("Stop and Start Process", 387, (40 * $i), 147, 25)
    $aReboot[$i] = GUICtrlCreateButton("Reboot", 582, (40 * $i), 100, 25)
Next

 and with this doesent work

 

For $i = 0 To 3
    GUICtrlCreateLabel($aComputer[$i - 1][0], 15, (40 * $i), 100, 26)
    GUICtrlSetFont(-1, 14, 400, 0, "Arial")
    $aInput[$i] = GUICtrlCreateInput("Status", 136, (40 * $i), 150, 21)
    $aStop_Start[$i] = GUICtrlCreateButton("Stop and Start Process", 387, (40 * $i), 147, 25)
    $aReboot[$i] = GUICtrlCreateButton("Reboot", 582, (40 * $i), 100, 25)
Next

 

  • Moderators
Posted

lexus,

Did you actually read what I posted at #21 above? That is the change you need to make - water's suggestion will not work as I explained in #23 above.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

sorry Melba23,

have not seen exactly. it works now.

when one computer offline is, is it possible the input field background color or font color with the  "if else" to changed ? 

  • Moderators
Posted

lexus,

Yes - use an If to check the return value and then a suitable GUICtrlSetBkColor on the input. You might also want to se the $ES_READONLY style for the inputs so that the user cannot change them.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

I would do it something like this

but, it´s not working

 

Func _Update($iIndex)

    $status = WMI_ProcessExists($aComputer[$iIndex][0], "POWERPNT.exe")
    Switch $status
        Case 0
            $aComputer[$iIndex][1] = "Online"
        Case 1
            $aComputer[$iIndex][1] = "Process run"
        Case Else
            $aComputer[$iIndex][1] = "Offline"

    EndSwitch
    ; Set status into input
    GUICtrlSetData($aInput[$iIndex + 1], $aComputer[$iIndex][1])

EndFunc

       $off = "Offline"

       $sInput_Text = GUICtrlRead($aInput[$iIndex + 1])
       If $sInput_Text <> $off Then

        $sInput_Content = $sInput_Text
         If $sInput_Content <> $off Then

            GUICtrlSetBkColor($aComputer[$iIndex][1], 0xFFCCCC)
        Else
            ;
            GUICtrlSetBkColor($aComputer[$iIndex][1], 0xFEFEFE)
        EndIf
     EndIf

 

  • Moderators
Posted

lexus,

And how is that going to work when the code is outside the function? AutoIt will never action the code as it will never be run.  But the If code itself if not too far away from what you need. I would however set the required input colour at the same time as the input content is determined - like this:

Func _Update($iIndex)

    ; Set default back colour
    $iBkColour = 0xFEFEFE
    $status = WMI_ProcessExists($aComputer[$iIndex][0], "POWERPNT.exe")
    Switch $status
        Case 0
            $aComputer[$iIndex][1] = "Online"
        Case 1
            $aComputer[$iIndex][1] = "Process run"
        Case Else
            $aComputer[$iIndex][1] = "Offline"
            ; Set offline colour
            $iBkColour = 0xFFCCCC

    EndSwitch
    ; Set status into input
    GUICtrlSetData($aInput[$iIndex + 1], $aComputer[$iIndex][1])
    ; Set input back colour
    GUICtrlSetBkColor($aInput[$iIndex + 1], $iBkColour)

EndFunc

And now you have had enough help for today. To be frank, you have shown very little understanding of how to code in AutoIt over the course of this thread. Most of your coding attempts to date have been so far off the mark as to be little more than useless - just code placed at random somewhere inside an existing script. Now while I understand that we all have to start somewhere, posting something like you did just now shows that you have absolutely no concept of how a script needs to flow internally. I suggest that before you start your next project you spend some time trying to understand the basic structure of an AutoIt script - the script I have just written for you would be a good place to start. Try working through the code line by line to see how the script moves from one section to another, calling various functions as it goes. If you can get a good handle on the overall logic flow it will help you write your next script with less input from others.

And feel free to ask questions if you do not follow the flow of the script - we are here to help you become a better coder, not to write your scripts for you. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

you're right. and I will learn autoit.

this was my first project and im happy thats finished.

thank you so much for your help and support.

  • Moderators
Posted

lexus,

Glad I could help. And I am serious about asking questions if you feel the need. Do not worry if they appear simple - but do read the Help file carefully before posting!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

I have one more question...

It is very costly to monitoring two processes more ?

or computer1 & computer2 & computer3  process  explorer.exe

computer4 & computer5 &computer6     process calc.exe

 must de code be changed much ?

  • Moderators
Posted

lexus,

I have no idea as I have not seen the code you are currently using. Please post your script and then we can see.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

now is the monitoting for 5 computer process powerpnt.exe

$status = WMI_ProcessExists($aComputer[$iIndex][0], "POWERPNT.exe")

i need for 1 computer the process only iexplore.exe

2 for process only excel.exe

and all other computer (it´s coming more) the process only powerpnt.exe.

 

 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>


Global $aInput[6], $aStop_Start[6], $aReboot[6]
; 2D array whereas 1st entry is the hostname and 2nd entry is for the status
Global $aComputer[5][2] = [["computer1", ""], ["computer2", ""], ["computer3", ""], ["computer4", ""], ["computer5", ""]]
Global $status, $result
Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")







$Form1_1_1 = GUICreate("Form1", 701, 598, 414, 91, BitOR($WS_MINIMIZEBOX,$WS_POPUP,$WS_GROUP))




For $i = 1 To 5

    GUICtrlCreateLabel($aComputer[$i - 1][0], 15, (40 * $i), 100, 26)
    GUICtrlCreateLabel("", 100, 26)
    GUICtrlSetFont(-1, 14, 400, 0, "Arial")
    $aInput[$i] = GUICtrlCreateInput("Status", 240, (40 * $i), 100, 21)
    $aStop_Start[$i] = GUICtrlCreateButton("Stop and Start Presentation", 387, (40 * $i), 147, 25)
    $aReboot[$i] = GUICtrlCreateButton("Reboot", 582, (40 * $i), 100, 25)
    GUICtrlSetBkColor(-1, 0xDEB887)



Next

$cUpdating = GUICtrlCreateLabel("", 242  , 556, 97, 25)


$btn_close = GUICtrlCreateButton("Close", 584, 556, 98, 17)
GUICtrlSetBkColor(-1, 0xFF9933)

GUISetState(@SW_SHOW)

; Initialise all the status inputs
SplashTextOn("Initialising", "", 70, 1, 415, 660)


For $i = 0 To UBound($aComputer) - 1
    _Update($i)
Next

SplashOff()

; Set an index for the status checks
$iIndex = 0
; Set a timestamp
$nBegin = TimerInit()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $btn_close
            Exit


        Case Else
            For $i = 1 To 5

                If $iMsg = $aStop_Start[$i] Then
                     RunWait ("c:\windows\pstools\pskill  \\" & $aComputer[$i -1][0] & "  -u user -p password POWERPNT.exe -accepteula")
             Sleep(5000)


              RunWait('c:\windows\pstools\psexec.exe  \\'& $aComputer[$i -1][0] & '  -u user -p password -i 1 -high "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\*.*" ')
                    ExitLoop
                EndIf
             Next


            For $i = 1 To 5
                If $iMsg = $aReboot[$i] Then
                     RunWait  ("c:\windows\pstools\psshutdown.exe  \\" & $aComputer[$i -1][0] & " -u user -p password -f -r -t 3 -accepteula")
                    ExitLoop
                EndIf

             Next

EndSwitch


    ; Every 5 secs
    If TimerDiff($nBegin) > 5000 Then
        ; Disable GUI & display label
        GUICtrlSetData($cUpdating, "Updating")
        GUISetState(@SW_DISABLE, $Form1_1_1)
        ; Check a computer
        _Update($iIndex)
        ; Set the index for the next check
        $iIndex += 1
        If $iIndex = 4 Then $iIndex = 0
        ; Reset the timestamp
        $nBegin = TimerInit()
        ; Re-enable GUI & clear label
        GUISetState(@SW_ENABLE, $Form1_1_1)
        GUICtrlSetData($cUpdating, "")
    EndIf

WEnd

Func _Update($iIndex)

    ; Set default back colour
    $iBkColour = 0xFEFEFE
    $status = WMI_ProcessExists($aComputer[$iIndex][0], "POWERPNT.exe")
    Switch $status
        Case 0
            $aComputer[$iIndex][1] = "Online"
        Case 1
            $aComputer[$iIndex][1] = "Process run"
            $iBkColour = 0xB0E0E6
        Case Else
            $aComputer[$iIndex][1] = "Offline"

            ; Set offline colour
            $iBkColour = 0xFFCCCC

    EndSwitch
    ; Set status into input
    GUICtrlSetData($aInput[$iIndex + 1], $aComputer[$iIndex][1])
    ; Set input back colour
    GUICtrlSetBkColor($aInput[$iIndex + 1], $iBkColour)



EndFunc



Func WMI_ProcessExists($host, $processname, $usr = "", $pass = "") ;coded by UEZ 2011
    If $host = "." Or $host = "localhost" Or $host = @IPAddress1 Or $host = @ComputerName Then
        If ProcessExists($processname) Then Return 1
        Return 0
    Else
        Local $ping = Ping($host, 1000)
        If @error Then Return SetError(1, 0, -1) ; Host not pingable
        Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator")
        Local $objWMIService = $objWMILocator.ConnectServer($host, "\root\cimv2", $usr, $pass, "", "", "&H80")
        If @error Then Return SetError(3, 0, -1)
        Local $colItems = $objWMIService.ExecQuery("SELECT Name FROM Win32_Process WHERE Name='" & $processname & "'", "WQL", 0x30)
        If IsObj($colItems) Then
            For $objItem In $colItems
                If $objItem.Name <> "" Then Return 1
            Next
        Else
            Return SetError(4, 0, -1)
        EndIf
        Return 0
    EndIf
EndFunc   ;==>WMI_ProcessExists

 

  • Moderators
Posted

lexus,

if I understand you correctly this script should do what you want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Global $aInput[6], $aStop_Start[6], $aReboot[6]
; 2D array whereas 1st entry is the hostname, 2nd entry is for the status and 3rd for the process to monitor
Global $aComputer[5][3] = [["computer1", "", "iexplore.exe"], _
                           ["computer2", "", "excel.exe"], _
                           ["computer3", "", "powerpnt.exe"], _
                           ["computer4", "", "powerpnt.exe"], _
                           ["computer5", "", "powerpnt.exe"]]
Global $status, $result
Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")

$Form1_1_1 = GUICreate("Form1", 701, 598, 414, 91, BitOR($WS_MINIMIZEBOX, $WS_POPUP, $WS_GROUP))

For $i = 1 To 5
    GUICtrlCreateLabel($aComputer[$i - 1][0], 15, (40 * $i), 100, 26)
    GUICtrlCreateLabel("", 100, 26)
    GUICtrlSetFont(-1, 14, 400, 0, "Arial")
    $aInput[$i] = GUICtrlCreateInput("Status", 240, (40 * $i), 100, 21)
    $aStop_Start[$i] = GUICtrlCreateButton("Stop and Start Presentation", 387, (40 * $i), 147, 25)
    $aReboot[$i] = GUICtrlCreateButton("Reboot", 582, (40 * $i), 100, 25)
    GUICtrlSetBkColor(-1, 0xDEB887)
Next

$cUpdating = GUICtrlCreateLabel("", 242, 556, 97, 25)

$btn_close = GUICtrlCreateButton("Close", 584, 556, 98, 17)
GUICtrlSetBkColor(-1, 0xFF9933)

GUISetState(@SW_SHOW)

; Initialise all the status inputs
SplashTextOn("Initialising", "", 70, 1, 415, 660)

For $i = 0 To UBound($aComputer) - 1
    _Update($i)
Next

SplashOff()

; Set an index for the status checks
$iIndex = 0
; Set a timestamp
$nBegin = TimerInit()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $btn_close
            Exit

        Case Else
            For $i = 1 To 5

                If $iMsg = $aStop_Start[$i] Then
                    ; Select the computer name and the process to monitor
                    RunWait("c:\windows\pstools\pskill  \\" & $aComputer[$i - 1][0] & "  -u user -p password " & $aComputer[$i - 1][2] & " -accepteula")
                    Sleep(5000)
                    RunWait('c:\windows\pstools\psexec.exe  \\' & $aComputer[$i - 1][0] & '  -u user -p password -i 1 -high "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\*.*" ')
                    ExitLoop
                EndIf
            Next

            For $i = 1 To 5
                If $iMsg = $aReboot[$i] Then
                    RunWait("c:\windows\pstools\psshutdown.exe  \\" & $aComputer[$i - 1][0] & " -u user -p password -f -r -t 3 -accepteula")
                    ExitLoop
                EndIf
            Next

    EndSwitch


    ; Every 5 secs
    If TimerDiff($nBegin) > 5000 Then
        ; Disable GUI & display label
        GUICtrlSetData($cUpdating, "Updating")
        GUISetState(@SW_DISABLE, $Form1_1_1)
        ; Check a computer
        _Update($iIndex)
        ; Set the index for the next check
        $iIndex += 1
        If $iIndex = 4 Then $iIndex = 0
        ; Reset the timestamp
        $nBegin = TimerInit()
        ; Re-enable GUI & clear label
        GUISetState(@SW_ENABLE, $Form1_1_1)
        GUICtrlSetData($cUpdating, "")
    EndIf

WEnd

Func _Update($iIndex)

    ; Set default back colour
    $iBkColour = 0xFEFEFE
    $status = WMI_ProcessExists($aComputer[$iIndex][0], "POWERPNT.exe")
    Switch $status
        Case 0
            $aComputer[$iIndex][1] = "Online"
        Case 1
            $aComputer[$iIndex][1] = "Process run"
            $iBkColour = 0xB0E0E6
        Case Else
            $aComputer[$iIndex][1] = "Offline"

            ; Set offline colour
            $iBkColour = 0xFFCCCC

    EndSwitch
    ; Set status into input
    GUICtrlSetData($aInput[$iIndex + 1], $aComputer[$iIndex][1])
    ; Set input back colour
    GUICtrlSetBkColor($aInput[$iIndex + 1], $iBkColour)

EndFunc   ;==>_Update

Func WMI_ProcessExists($host, $processname, $usr = "", $pass = "") ;coded by UEZ 2011
    If $host = "." Or $host = "localhost" Or $host = @IPAddress1 Or $host = @ComputerName Then
        If ProcessExists($processname) Then Return 1
        Return 0
    Else
        Local $ping = Ping($host, 1000)
        If @error Then Return SetError(1, 0, -1) ; Host not pingable
        Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator")
        Local $objWMIService = $objWMILocator.ConnectServer($host, "\root\cimv2", $usr, $pass, "", "", "&H80")
        If @error Then Return SetError(3, 0, -1)
        Local $colItems = $objWMIService.ExecQuery("SELECT Name FROM Win32_Process WHERE Name='" & $processname & "'", "WQL", 0x30)
        If IsObj($colItems) Then
            For $objItem In $colItems
                If $objItem.Name <> "" Then Return 1
            Next
        Else
            Return SetError(4, 0, -1)
        EndIf
        Return 0
    EndIf
EndFunc   ;==>WMI_ProcessExists

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Hi,

yes , but this is for kill or run process

Global $aComputer[5][3] = [["computer1", "", "iexplore.exe"], _
                           ["computer2", "", "excel.exe"], _
                           ["computer3", "", "powerpnt.exe"], _
                           ["computer4", "", "powerpnt.exe"], _
                           ["computer5", "", "powerpnt.exe"]]





If $iMsg = $aStop_Start[$i] Then
                    ; Select the computer name and the process to monitor
                    RunWait("c:\windows\pstools\pskill  \\" & $aComputer[$i - 1][0] & "  -u user -p password " & $aComputer[$i - 1][2] & " -accepteula")
                    Sleep(5000)
                    RunWait('c:\windows\pstools\psexec.exe  \\' & $aComputer[$i - 1][0] & '  -u user -p password -i 1 -high "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\*.*" ')
                    ExitLoop
                EndIf

would not supplementing to monitoring a process ?

the next step would....

 

$status = WMI_ProcessExists($aComputer[$iIndex][0], "$aComputer[$i - 1][2]")

 

 

 

 

  • Moderators
Posted (edited)

lexus,

I think I understand now - and you were very close, you just need to remove the quotes:

$status = WMI_ProcessExists($aComputer[$iIndex][0], $aComputer[$iIndex][2])

M23

Edited by Melba23
Amended code

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

what you wrote i understand.

but i don´t understand why $iIndex.

with $aComputer[$iIndex][2] works.

 

$status = WMI_ProcessExists($aComputer[$iIndex][0], $aComputer[$iIndex][2])

 

  • Moderators
Posted

exus,

My error (and my excuse is that I am currently working on 3 different help problems at the same time) - I should have posted:

$status = WMI_ProcessExists($aComputer[$iIndex][0], $aComputer[$iIndex][2])

The idea is that the loop runs the query for each computer in turn and passes the name of the associated process.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...