microera

ProcessExists ( "process" ) over LAN

16 posts in this topic

Hi

 

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?

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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
1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

very good "water"!!

And how send pop up message from Computer1 to Computer2 if I try run PROGRAMM.EXE  from Computer1?

(in example detecting running PROGRAMM.EXE in Computer2)

Possible also with WMI? Or I need any other service?!

 

 

Share this post


Link to post
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.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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?

 

Share this post


Link to post
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.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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"

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

 

Share this post


Link to post
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!

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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. 

Share this post


Link to post
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.

 

Share this post


Link to post
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