Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:16:32+00:00 2026-05-28T06:16:32+00:00

I am trying to retrieve all processes running on a machine with the usual

  • 0

I am trying to retrieve all processes running on a machine with the usual information; process id, name and the memory usage. im trying to export it all under one xml file, however to get all the information i had to use 2 separate methods.

to get the process id, name and session id (process owner) i used the following code along with a dictionary and a class, usng a .net library called Cassia.

Using server As ITerminalServer = manager.GetRemoteServer("Spartacus")
        server.Open()
        For Each process As ITerminalServicesProcess In server.GetProcesses()
            If Not String.IsNullOrEmpty(process.ProcessId) Then
                dictprocess.Add(process.ProcessId, New Processes(process.ProcessId, process.ProcessName, process.SessionId))
            End If
        Next
    End Using

    Dim sbProcess As New StringBuilder
    sbProcess.AppendLine("<?xml version=""1.0""?>")
    sbProcess.AppendLine("<Processes>")
    For Each item As KeyValuePair(Of Integer, Processes) In dictprocess
        sbProcess.AppendFormat("<Name>""{0}""<ProcessID>""{1}""</ProcessID><ProcessName>{2}</ProcessName><SessionID>{3}</SessionID></Name>", item.Key, item.Value.ProcessId, item.Value.ProcessName, item.Value.SessionId).AppendLine()
    Next
    sbProcess.AppendLine("</Processes>")

in order to get the memory and page file usage i used a wmi query

   Dim sbTest As New System.Text.StringBuilder

    objWMI = GetObject("winmgmts:\\.\root\cimv2")
    colObjects = objWMI.ExecQuery("Select * From Win32_Process")

    For Each Item In colObjects
        sbTest.AppendFormat("<ProcessID>""{0}""<ProcessName>""{1}""</ProcessName><MemoryUsage>{2}</MemoryUsage><PageFileUsage>{3}</PageFileUsage></ProcessID>", Item.ProcessID, Item.Name, (Item.WorkingSetSize / 1024), Item.PageFileUsage)
    Next

I can write the results as two separate xml files:

Process id, name and session id:

- <Processes>
- <Name>
  "540" 
  <ProcessID>"540"</ProcessID> 
  <ProcessName>wininit.exe</ProcessName> 
  <SessionID>0</SessionID> 
  </Name>
- <Name>
  "552" 
  <ProcessID>"552"</ProcessID> 
  <ProcessName>csrss.exe</ProcessName> 
  <SessionID>1</SessionID> 

Process memory and page file usage

- <ProcessUsage>
- <ProcessID>
  "540" 
  <ProcessName>"wininit.exe"</ProcessName> 
  <MemoryUsage>4080</MemoryUsage> 
  <PageFileUsage>1464</PageFileUsage> 
  </ProcessID>
- <ProcessID>
  "552" 
  <ProcessName>"csrss.exe"</ProcessName> 
  <MemoryUsage>5600</MemoryUsage> 
  <PageFileUsage>2332</PageFileUsage> 
  </ProcessID>

As you can see the unique id (process id) is the same in each xml. Is there any way i can write the xml so that the information from both methods can be under one tag?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:16:33+00:00Added an answer on May 28, 2026 at 6:16 am

    In general you can create a class which has members that have all the data you would like to collect. Then utilize some type of container ( I would suggest a dictionary keyed on process id) modify your function to take said container. If the process id is found within the container update the fields you want if it is not found add the entry. Then loop though the container and write the xml.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve all the file name under ScheduleFolder and place it
I'm trying to build a script to retrieve all feed entries from a given
I'm trying to retrieve db sizes of all databases in my SQL Server 2005
I am trying to retrieve the attribute name and type that exist in an
I'm trying to retrieve all the addresses from the address book and display them
I'm not the greatest with LINQ, but I'm trying to retrieve all the ModuleAvailabilities
I am trying to retrieve all cards from Mongoid that have request=preview I'm doing
I'm trying to retrieve all rows inserted during a specific month. SELECT dbo.Post.UserId, dbo.Post.Tags,
I m trying to retrieve all the data in the isolated storage file. But
I'm trying to retrieve all the photos a user is tagged in using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.