473,804 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the command line switches for processes.

I am looping through the array of processes returned by
Process.GetProc esses(). 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.StartIn fo.Arguments property but it is always empty.

Thanks.
Nov 4 '06 #1
1 4396

"Frank Rizzo" <no**@none.comw rote in message
news:u$******** ******@TK2MSFTN GP02.phx.gbl...
|I am looping through the array of processes returned by
| Process.GetProc esses(). 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.StartIn fo.Arguments property but it is always empty.
|
| Thanks.

Using System.Manageme nt and WMI, here is a sample:

SelectQuery selectQuery = new SelectQuery("se lect * from
Win32_Process") ;
using(Managemen tObjectSearcher searcher = new
ManagementObjec tSearcher(selec tQuery))
{
foreach(Managem entObject process in searcher.Get())
{
string commandLine = process.Propert ies["CommandLin e"].Value;
Console.WriteLi ne(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
883
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 options.txt`" and I was turned to the specs option
7
5225
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 command switches like. C:\FooApp\Foobar.exe /quiet that the application will load and process tasks with no user input, but when C:\FooApp\Foobar.exe is run that it would load my windows form interface. Does that make sense? Can anyone help me...
2
2561
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 Shared\MSInfo\msinfo32.exe /?") I have a couple other command line tools with switches that I would like to programmatically execute as well. I'm thinking there is another way to do this but am coming up short. Any help is greatly appreciated.
3
1647
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
1875
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 command line. I noticed that visual studio adds the following for you when creating a new CLI program: void main(string args) { }
17
2007
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 something like this but the switches could be in any order and not all may be used. -m quemanager -s server -p port -k key -o object -c 20 -t test@email.com
3
4059
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 Windows every fifteen minutes. I'd like to supply a command line switch (like "C:\Program Files\My Program\MyProg.exe /Auto") so the program will run without displaying the user interface. BUT, I'd like to show the interface if the command line...
0
1055
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 SysInternals' Process Explorer? Thanks.
6
1956
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 Application Pool to use a Web Garden and the number of Context Switches decreased by more than 95% (that's the good news). Our problem is that we have something in our session state that cannot be serialized and therefore we cannot use StateServer for...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10320
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7620
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.