473,387 Members | 1,495 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,387 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 4358

"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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.