Take the 2-minute tour ×

We have an application that calls an executable on the user's PC (Windows 7), however it's looking for a hard coded path that may or may not be accurate. i.e. There are users who have installed the executable to other than the default location. I thought I could just make a simple batch file that would determine where the executable actually resides and then make a symlink to its directory:

forfiles /m dirname /s /c "cmd mklink /d correct_dirname @relpath"

The problem is that this only searches in the current directory which may or may not be the right place to start. If I use the forfiles /p flag (to specify the search path) and look from C: I get extraneous shortcuts and helpfiles that aren't what I'm looking for, as well as "Access denied" to system directories. Besides I can't be sure that the user hasn't installed to E: for example.

I need to locate the executable which could be anywhere on the user's PC. \Program files\application is the default location but not certain. Am I missing something obvious here and/or is there a more elegant solution?

Thank you.

share|improve this question
Perhaps you can query the app's registry key (if nothing else look for the Uninstall key) and get the path from there? –  Karan Mar 8 '13 at 20:56
add comment


Your Answer



Browse other questions tagged or ask your own question.