473,439 Members | 5,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,439 software developers and data experts.

Getting the command line switches for processes.

I am looping through the array of processes returned by
Process.GetProcesses(). How do I get the command line parameters that
each of the processes was started with? Kind of like in the
SysInternals' Process Explorer?

I've tried Process.StartInfo.Arguments property but it is always empty.

Thanks.
Nov 4 '06 #1
1 4361

"Frank Rizzo" <no**@none.comwrote in message
news:u$**************@TK2MSFTNGP02.phx.gbl...
|I am looping through the array of processes returned by
| Process.GetProcesses(). How do I get the command line parameters that
| each of the processes was started with? Kind of like in the
| SysInternals' Process Explorer?
|
| I've tried Process.StartInfo.Arguments property but it is always empty.
|
| Thanks.

Using System.Management and WMI, here is a sample:

SelectQuery selectQuery = new SelectQuery("select * from
Win32_Process");
using(ManagementObjectSearcher searcher = new
ManagementObjectSearcher(selectQuery))
{
foreach(ManagementObject process in searcher.Get())
{
string commandLine = process.Properties["CommandLine"].Value;
Console.WriteLine(commandLine);
}
}

Note that you need administaror privileges to get the process properties of
all running processes!

Willy.
Nov 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rolf Hemmerling | last post by:
Hello ! How to let GPP/GCC read command line switches from a file, **for Windows** ? I was told a Linux solution: "Your options in options.txt Then: gcc $(cat options.txt) or: gcc `cat...
7
by: John Wildes | last post by:
Hello All, I've got a VB.net windows form app that I have created to solve some recurring maintenance tasks. What I would like to do is build functionality into this application so that accepts...
2
by: Mike W | last post by:
I'm trying to programmatically run msinfo32.exe /? with the following line of code but it is not taking the switch: System.Diagnostics.Process.Start("c:\program files\common files\Microsoft...
3
by: kitty | last post by:
Can i provide for command line switches in c++ ? For example i can say perl readfile.pl -f filename, Is g++ readfile.cc -f filename possible ? Thankyou for all you help,.
8
by: djc | last post by:
I'm new to this and was wondering what the options are for interpreting the command line using a CLI program. Specifically methods for interpreting the parameters passed to the program on the...
17
by: News | last post by:
Hi everyone, My goal is to pull command switches/options from a file and then assign the values to select variables which would eventually be included in a class object. The data file looks...
3
by: Rico | last post by:
Hello, I'm new to VB.net and I have an application that I would like to open up in one of two different modes depending on a command line switch. The code will run as a scheduled task in...
0
by: Frank Rizzo | last post by:
I am looping through the array of processes returned by Process.GetProcesses(). How do I get the command line parameters that each of the processes was started with? Kind of like in the...
6
by: =?Utf-8?B?QnJlbmRhbiBLYXk=?= | last post by:
Hi there, We have an ASP.Net application that is generating huge numbers of Context Switches when a certain number of active users are present. We tried changing the configuration of the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.