473,503 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

path of a process or service

Hi,
I need the directory of a running process or service's executable. Any
ideas how to do this?

I looked up some Win APIs but none to accomplish this task.

I noticed there is a .StartInfo.WorkingDirectory in the process object
but it is always empty. I would think that the working dir would be the
same as the EXE if not defined.

Aug 31 '06 #1
5 1787
System.Diagnostics.Process.MainModule.FileName

<wh*******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,
I need the directory of a running process or service's executable. Any
ideas how to do this?

I looked up some Win APIs but none to accomplish this task.

I noticed there is a .StartInfo.WorkingDirectory in the process object
but it is always empty. I would think that the working dir would be the
same as the EXE if not defined.

Aug 31 '06 #2
The only option I see in C# is
string AppPath = System.Windows.Forms.Application.StartupPath;
MessageBox.Show(AppPath);

I think you can google and find better option if this doesn't work.
Regards,
Rajesh
Siva M wrote:
System.Diagnostics.Process.MainModule.FileName

<wh*******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,
I need the directory of a running process or service's executable. Any
ideas how to do this?

I looked up some Win APIs but none to accomplish this task.

I noticed there is a .StartInfo.WorkingDirectory in the process object
but it is always empty. I would think that the working dir would be the
same as the EXE if not defined.
Aug 31 '06 #3
The only option I see in C# is
string AppPath = System.Windows.Forms.Application.StartupPath;
MessageBox.Show(AppPath);

I think you can google and find better option if this doesn't work.
Regards,
Rajesh
Siva M wrote:
System.Diagnostics.Process.MainModule.FileName

<wh*******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,
I need the directory of a running process or service's executable. Any
ideas how to do this?

I looked up some Win APIs but none to accomplish this task.

I noticed there is a .StartInfo.WorkingDirectory in the process object
but it is always empty. I would think that the working dir would be the
same as the EXE if not defined.
Aug 31 '06 #4
Rob
On 31 Aug 2006 09:33:54 -0700, wh*******@gmail.com wrote:
>Hi,
I need the directory of a running process or service's executable. Any
ideas how to do this?
The current process?
Process.GetCurrentProcess().MainModule.FileName;
Sep 1 '06 #5
Environment.CommandLine has full path and exe name in it.
<wh*******@gmail.comha scritto nel messaggio
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,
I need the directory of a running process or service's executable. Any
ideas how to do this?

I looked up some Win APIs but none to accomplish this task.

I noticed there is a .StartInfo.WorkingDirectory in the process object
but it is always empty. I would think that the working dir would be the
same as the EXE if not defined.

Sep 1 '06 #6

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

Similar topics

5
6730
by: | last post by:
Hi, I have a Windows Service that uses a referenced dotnet-dll. In my dll I set some public string to a stringvalue that I get from reading a xml-file(my config file). It works fine if I use it...
1
3701
by: Theerachet Pratoommanee | last post by:
This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ----------------------------------------------------------------------------...
7
19597
by: Eric.Jones | last post by:
I've encountered a strange error with loading delimited files from a Samba (SMB) network drive, has anyone else seen this before? (Platform: WinXP Pro, UDB PE 8015, level 02060106, SAMPLE db) ...
2
3961
by: gordingin | last post by:
I need to get the path of a service in C#. Using C++, I can use QueryServiceConfig() but I wish not to use Interop if I dont have to, is there a way in C#? thanks Ralph
1
3978
by: Johan | last post by:
Hi all I'm trying to set the permissions of a file using WMI, and since i'm writing a windows service i want to use UNC paths doing this because the destination might not be a mapped path. I'we...
3
7945
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
7
19719
by: hufaunder | last post by:
I have a website that uses a web service that is located on the same machine. This webservice calls a program which in return modifies a file in c:\documents and Settings\All Users\Application...
1
1950
by: =?Utf-8?B?Tko=?= | last post by:
Hi everyone, Every now and then I'm receiving the error posted below. I"m routing all my traffic through mod_proxy (apache) to my asp.net 2.0 (w2k3) machine. I can't reproduce this error and my...
12
3686
by: Anil Gupte | last post by:
I wrote my Windows Service first as a regular Windows Exe because it is easier to debug. In that I used AppDir = Application.ExecutablePath.Substring(0,...
0
7202
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
7086
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...
0
7330
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
7460
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
5578
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
4672
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
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
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...

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.