Invoke vb.net code with object class ManagementObjectSearcher

Hi forum,

** UIPath Version 19.7.0.0

I want to add a function to check whether there are any running java applications containing special keyword in the command line of the process.

This could be done by this VB.net code:

Dim isRunning As Boolean = False
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(“SELECT * FROM Win32_Process WHERE Name=‘java.exe’ OR Name=‘javaw.exe’”)
For Each process As ManagementObject In searcher.Get()
Dim cmdlparam As String = process(“CommandLine”)
If cmdlparam.ToLower.Contains(“function.exe”) Or cmdlparam.ToLower.Contains(“service.jar”) Then
isRunning = True
End If
Next

To run this I need to import Microsoft “System.Management” package.
But after installing the package (V4.5.0) UIPath shows error “package installation failure”.

The Activity “Get Processes” does not help, as I can not get the commandline parameters of the running processes.

Does anyone have an idea ?

Thomas

Did you try to import it below?
image

Yes I already tried, but I need the “father” class: System.Management

sysmn3
Does anyone know, why loading the System.Management package fails ?

Hi @kuktom019

Welcome to our UiPath Forum! :slight_smile:

Would this solution help here maybe? (naturally with your particular namespace)

Hi @loginerror,

unfortunately it didn’t help.

But this works:
Instead of adding reference to “System.Management” (by Microsoft) I added “System.Management.dll” by dongz:

1 Like

Hi @loginerror,

sorry, finally found this solution:

Just adding the right namespace “System.Management.Instrumentation” leads to an automatically adding of Assembly Reference “System.Management”.
And the code is working correctly :wink:

1 Like