Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
We have our windows application installed in client's (10 laptops) pc's. We don't know the installation path there but now we have made some alterations in the application. Now need to change the exe and dll files in client pc's by running a patch file. we know the names of these files but don't know the installation path in client pc's. kindly provide us the c# code to do the same...
Posted

1 solution

Hi This is what you need: Getting installed app path in C#[^]

Or
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;
}

Use it like so:
SQL
string pathToExe = GetPathForExe("wmplayer.exe");

However, it may very well be that the application that you want does not have an App Paths key.Source[^]


I hope it's helps.
 
Share this answer
 
v2
Comments
jimmi mohanan 2-Apr-12 2:42am    
thanks for your reply....i am checking the article now
jimmi mohanan 2-Apr-12 3:05am    
Hi,
Actually i am getting the description but not always return the path...
jimmi mohanan 2-Apr-12 5:36am    
Thanks...i got the desired directory. Thank you very much
Roman Lerman 2-Apr-12 6:19am    
Please mark it as Accepted Answer.
I was glad to help.

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