Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# C#4.0
Hello i am trying to get path of an installed application
How can i achieve this


Currently i am trying to use
String path = Environment.GetEnvironmentVariable("path");

but this doesnot give the application path .. here i am trying to get the vpnClient.exe
Posted 28-Sep-12 23:37pm
arun_pk1.4K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Please Try the code below

String path = System.Windows.Forms.Application.StartupPath;

Regards,
Ahmed Mandour
  Permalink  
v2
Comments
arun_pk at 29-Sep-12 5:36am
   
Application ?? please say the namespace
Ahmed Mandur at 29-Sep-12 5:40am
   
I have edited the solution with your last requirements
Regards,
arun_pk at 29-Sep-12 12:10pm
   
Sorry this is not at all what i was asking for...
arun_pk at 29-Sep-12 12:11pm
   
but this doesnot give the application path .. here i am trying to get the vpnClient.exe

this is what i was looking for
the answer you given was no where related to this..
sorry to say this..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Sorry for misunderstood
here is the code that will find the execution path of installed application

private const string keyBase = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths";
 
        private string GetPathForExe(string fileName)
        {
            RegistryKey localMachine = Registry.LocalMachine;
            RegistryKey fileKey = localMachine.OpenSubKey(string.Format(@"{0}\{1}", keyBase, fileName));
            object result = null;
            if (fileKey != null)
            {
                result = fileKey.GetValue(string.Empty);
            }
            fileKey.Close();
 
            return (string)result;
        } 

To use this code Eg.:

 string Path = GetPathForExe("firefox.exe");

Regards,
Ahmed Mandour
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 255
1 Sebastiaan Meijerink 141
2 Sergey Alexandrovich Kryukov 124
3 Abhinav S 94
4 Maciej Los 84
0 Sergey Alexandrovich Kryukov 6,558
1 OriginalGriff 6,288
2 Peter Leow 2,534
3 Abhinav S 2,358
4 Maciej Los 2,352


Advertise | Privacy | Mobile
Web01 | 2.8.150414.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100