Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to get list of open processes into the fi
Message
General information
Forum:
Windows
Category:
Troubleshooting
Miscellaneous
Thread ID:
01320331
Message ID:
01320368
Views:
12
This message has been marked as a message which has helped to the initial question of the thread.
>>>>How about WMI?
>>>
>>>Good idea. Can you please give me a script file?
>>>
>>>Thanks.
>>
>>
>>loLocator			= CREATEOBJECT('WBEMScripting.SWBEMLocator')
>>loWMI				= loLocator.ConnectServer()
>>loProcesses			= loWMI.ExecQuery([SELECT * FROM Win32_Process])
>>
>>For Each loProcess in loProcesses
>>	? loProcess.Caption, loProcess.Name, loProcess.ProcessID, Nvl(loProcess.ExecutablePath, '')
>>Next
>>
>
>Thanks a lot, Hugo, but I don't need it in VFP code.
>
>Anyway, in the meantime I found the problem. Somehow one unrelated page got included into the project. In other words, the error I was getting was not even from the page I was working on, but was coming from another test page. Cost me several hours :(

C#:
using System;
using System.Management;
using System.Windows.Forms;

namespace WMISample
{
    public class MyWMIQuery
    {
        public static void Main()
        {
            try
            {
                ManagementObjectSearcher searcher = 
                    new ManagementObjectSearcher("root\\CIMV2", 
                    "SELECT * FROM Win32_Process"); 

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("Win32_Process instance");
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("Name: {0}", queryObj["Name"]);
                }
            }
            catch (ManagementException e)
            {
                MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
            }
        }
    }
}
VB.NET:
Imports System
Imports System.Management
Imports System.Windows.Forms

Namespace WMISample

    Public Class MyWMIQuery

        Public Overloads Shared Function Main() As Integer

            Try
                Dim searcher As New ManagementObjectSearcher( _
                    "root\CIMV2", _
                    "SELECT * FROM Win32_Process") 

                For Each queryObj As ManagementObject in searcher.Get()

                    Console.WriteLine("-----------------------------------")
                    Console.WriteLine("Win32_Process instance")
                    Console.WriteLine("-----------------------------------")
                    Console.WriteLine("Name: {0}", queryObj("Name"))
                Next
            Catch err As ManagementException
                MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
            End Try
        End Function
    End Class
End Namespace
Check that tool :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform