Link to home
Start Free TrialLog in
Avatar of mskannan
mskannan

asked on

How to get the full path of an existing file?

hi,
I want to shell an exe application from my visual basic application. When I run the shell command everything is working fine. But in my clients pc's that exe file may be anywhere(because while installing that program he can choose any folder). So I want to check where the file is and get the full path and shell this one. Suppose if he has c and d drives and the exe is in D drive, how to consider this case?

Any help,
mskannan
Avatar of Vbmaster
Vbmaster

How about storing in the registry the path to where you can find the file? This to be able to find the file quickly, instead of scanning thru all the harddrives. ;)
Avatar of mskannan

ASKER


hi vbmaster,
how to implement this?
i know we can use savesetting, getsetting apis but where to write this apis?
whether i have to write when the application first starts or during the installation of the software.
can you help?

mskannan.
It's SaveSetting and GetSetting, they are in the helpfiles (they are not API's but built in standard VB). What version of VB do you have? These are from VB5 and up, don't know about the earlier versions.

".. i have to write when the application first starts .."

Humm does this work, because as I understand it the user doesn't start this instead it's only executed via your other program. If this is the case it will be hard to execute the program first and THEN get the full filepath (where did it get it to execute it the first time? ;)).

".. or during the installation of the software .. "

This does sound like the best solution. You need to save the value in HKEY_CURRENT_USER\Software\VB and VBA Program Settings\your_program_name_here\ to be able to use the SaveSetting/GetSetting statements.
hi vbmaster,
how to call this function while setting up and not otherwise.

mskannan.
You mean that you want to save the value the first time the program executes? One solution would be to use the GetSetting function and if this returns a empty string/empty value or whatever it does when there is no such key, then just use SaveSetting to put in the filename there.
i think u whant to know the path of your  exe  Application ,how about app.path it will give u the Full path of your application

x = app.path
hi hatem72,
I can use app.path if i want to know the path of the exe I am running. But now what i want is, from my application I want to find some other exes full path (for example, where notepad.exe is in the user's system)
mskannan.
ASKER CERTIFIED SOLUTION
Avatar of LCP
LCP

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi LCP,

Your answer is excellant. Working for me fine. Only one glitch is that it works for only exes under Microsoft program group.
I tried changing the following line

"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\"

into

"SOFTWARE"
and tried running this function which gives an error message. Anyway for me,
winword.exe is enough.

Thank you very much,
mskannan
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.

This is the Community Support link, if help is needed, along with the link to All Topics since many new ones were recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thanks,
Moondancer
Moderator @ Experts Exchange