Would like to develop coding to print to a text file all of the names of my processes currently running!

Posted on 2007-10-17
Medium Priority
Last Modified: 2010-04-30
I have MS Visual Studio 6.0 with Visual Basic and want to create a function that would list all of my Processes (shown in the Windows Task Manager) in a text file - so I make the lookup on the internet as to what that file is that much quicker.

Has anyone ever posted that kind of code before?

I also have Visual Studio 2005 Standard Edition for Visual Basic to work utilizing .NET.
Any tips are much appreciated.
Question by:stephenlecomptejr
LVL 21

Accepted Solution

oleggold earned 1400 total points
ID: 20098641
LVL 18

Expert Comment

by:Ajay Sharma
ID: 20113955
u need code for vb6 or vb.net ?
LVL 18

Expert Comment

by:Ajay Sharma
ID: 20113988
u can also use

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 18

Expert Comment

by:Ajay Sharma
ID: 20113990
sorry for the above comment
Cancel it.

Author Comment

ID: 20114722
How about for VB.NET as well?
LVL 26

Expert Comment

ID: 20119251
Dim colProcesses As Object
   Dim objProcess As Object
   On Error Resume Next
   Set objWMIService = GetObject("winmgmts:")
   Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
   For Each objProcess In colProcesses
       Debug.Print objProcess.Caption, objProcess.executablepath
LVL 18

Assisted Solution

by:Ajay Sharma
Ajay Sharma earned 600 total points
ID: 20121659
u can download the source code for a task manager from here.


In the 174 th line it is listing the process to the listview

and modify the code as below

Imports System.io
Imports System
Imports System.Diagnostics

In the form load put this

Dim MachineName As String = System.Environment.MachineName.ToString
        Dim Prc() As Process
        Dim i As Integer
        Dim lvwP As ListViewItem
            Prc = Process.GetProcesses(MachineName)

            Dim streamError As New FileStream(Application.StartupPath & "processes.txt", FileMode.OpenOrCreate, FileAccess.Write)
            Dim tw As StreamWriter
            tw = New StreamWriter(streamError)
            tw.BaseStream.Seek(0, SeekOrigin.End)

            For i = 0 To UBound(Prc)

            lvwProcesses.Items.Add("Error enumerating items...")
        End Try

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question