Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
1.86/5 (4 votes)
See more:
How do I know the name of the process that will be run in vb.net

Example: run Firefox, I want my show a message written in the name of the operation "filefox.exe"
Posted
Comments
DinoRondelly 16-May-13 13:18pm    
Are you asking how do you know what processes are running?

1 solution

You may (or may not) be able to get the name you want - it depends on what process you start.
C#
Process p = new Process();
p.StartInfo.FileName = @"D:\Temp\MyText.txt";
p.Start();
Console.WriteLine(p.ProcessName);
Will almost certainly give you the process name "Notepad" (or in my case "PsPad") - but it may throw an "invalid operation" exception if you open (for example) an HTML file. On my system, that will open with Chrome, but since Chrome throws the request to an already running instance and terminates the process immediately so as not to generate a new window it doesn't work (because the Process ID is no longer running).

Still, it might be what you want, and it's pretty much the only way to get it...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900