Jump to content

ProcessExists ( "process" ) over LAN


microera
 Share

Recommended Posts

You could use WMI to get a list of processes. The example script "Scriptomatic" creates AutoIt code for you.
The following stripped down example returns a list of processes running on the other computer. Replace "." with the name of this computer.

; Generated by AutoIt Scriptomatic
#include <Array.au3>

Global $wbemFlagReturnImmediately = 0x10
Global $wbemFlagForwardOnly = 0x20
Global $colItems = ""
Global $strComputer = "."
Global $i = 0
Global $aResult[10000]

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) Then
    For $objItem In $colItems
        $aResult[$i] = $objItem.Caption
        $i = $i + 1
    Next
    ReDim $aresult[$i]
    _ArrayDisplay($aResult)
Else
    MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_Process")
EndIf

 

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

 

Link to comment
Share on other sites

You want to start from Computer 1 a program on Computer 2? Then PSExec seems to be the tool for you.

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

 

Link to comment
Share on other sites

You could use WMI to get a list of processes. The example script "Scriptomatic" creates AutoIt code for you.
The following stripped down example returns a list of processes running on the other computer. Replace "." with the name of this computer.

; Generated by AutoIt Scriptomatic
#include <Array.au3>

Global $wbemFlagReturnImmediately = 0x10
Global $wbemFlagForwardOnly = 0x20
Global $colItems = ""
Global $strComputer = "."
Global $i = 0
Global $aResult[10000]

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) Then
    For $objItem In $colItems
        $aResult[$i] = $objItem.Caption
        $i = $i + 1
    Next
    ReDim $aresult[$i]
    _ArrayDisplay($aResult)
Else
    MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_Process")
EndIf

 

On home computer work ok but on my Office computer:

>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\UPRAVLJAJ\wmi_lan_process_get.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\UPRAVLJAJ\wmi_lan_process_get.au3" (40) : ==> Variable must be of type "Object".:
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$colItems = $objWMIService^ ERROR
->14:14:22 AutoIt3.exe ended.rc:1
+>14:14:22 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 0.6572

Where is a problem?

 

Link to comment
Share on other sites

Please add a COM error handler to the script so we can see why ObjGet doesn't return an object. Please see ObjEvent in the help file for an example.

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

 

Link to comment
Share on other sites

from 1st example:

https://www.autoitscript.com/autoit3/docs/functions/ObjEvent.htm

    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
 
and
; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc
 

and get:

>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\UPRAVLJAJ\wmi_lan_process_get.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
wmi_lan_process_get.au3 (41) : ==> COM Error intercepted !
    err.number is:         0x80070005
    err.windescription:    Dostop je zavrnjen.

    err.description is:     
    err.source is:         
    err.helpfile is:     
    err.helpcontext is:     
    err.lastdllerror is:     0
    err.scriptline is:     41
    err.retcode is:     0x00000000

wmi_lan_process_get.au3 (42) : ==> COM Error intercepted !
    err.number is:         0x000000A9
    err.windescription:    Variable must be of type 'Object'.
    err.description is:     
    err.source is:         
    err.helpfile is:     
    err.helpcontext is:     
    err.lastdllerror is:     0
    err.scriptline is:     42
    err.retcode is:     0x00000000

+>14:47:38 AutoIt3.exe ended.rc:0
+>14:47:38 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 21.05

Link to comment
Share on other sites

Google translate tells me that the first message means: Access is denied.
Maybe this site describes what's going on.

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

 

Link to comment
Share on other sites

This site (https://msdn.microsoft.com/en-us/library/windows/desktop/aa394603(v=vs.85).aspx) is even more specific how to solve the problem. Search for "0x80070005"

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

 

Link to comment
Share on other sites

Access is denied solved  ......... but:

now:

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
wmi_lan_process_check.au3 (41) : ==> COM Error intercepted !
    err.number is:         0x800706BA
    err.windescription:    Strežnik za RPC ni na voljo.

    err.description is:     
    err.source is:         
    err.helpfile is:     
    err.helpcontext is:     
    err.lastdllerror is:     0
    err.scriptline is:     41
    err.retcode is:     0x00000000

 

Link to comment
Share on other sites

I'm enable this:

https://support.software.dell.com/enterprise-reporter/kb/116792

Windows 8 and Windows 8.1

In the lower left hand corned of the screen right click and select Control Panel.  Then select System and Security | Windows Firewall then select “Allow an app or feature through Windows Firewall”.  Scroll down and click on check box next to “File and Printer Sharing” and “Windows Management Instrumentation (WMI)” which should automatically select the check box in the Domain column.  Click OK. 

Next start the Remote Registry service which is set to Disabled by default (set to Automatic).  If not data such as installed software, event logs, security policies, etc. will not be retrieved.

 

but still same problem!

 

Link to comment
Share on other sites

0x800706BA stands for: RPC server is unavailable.
This site describes a few other possible causes for your problem.

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

 

Link to comment
Share on other sites

This site (https://msdn.microsoft.com/en-us/library/windows/desktop/aa394603(v=vs.85).aspx) is even more specific how to solve the problem. Search for "0x80070005"

..again I have this error: 0x80070005

Is possible with command lines setting WMI or access from comp1 <--> comp2

?

p.s.

I have win 8.1

 

p.s.2

I'm disable firewall but still same problem! :(

Link to comment
Share on other sites

Can't you talk to your network/computer admins and ask them for assistance? Helping with a problem I do not see here is a bit hard.
I'm sure it is a problem with firewall, GPOs or whatever and the admins know what they have changed on their systems.

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

 

Link to comment
Share on other sites

I have 2 PCs on local LAN! We start one programm.exe from 1st or 2nd computer!

But at same time must be running ONLY one process (programm.exe)! How to detect process on another PC?

Since is your network, and you have access to both, I'd write something on UDP  or TCP to announce it. Like a chat ( there are a lot of examples ) , because you are not limited to WMI.
Now, why the WMI fails, no clue, it should work. 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

@microera,

... must be running ONLY one process (programm.exe) ...

why?

most common cause is that they both access a shared resource (which may be sensitive to conflicts).

if this is your case, then use this UDF. it was written for cases where the shared resource is a file, but can be used for other types of resources. you don't need access between computers; you just need both to have access to a shared folder, which can exist anywhere.

 

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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