Windows 7 How to create a shortcut to a *.bat batch file in the SAME (unknown) folder?

pstein

Extraordinary Member
I have written a batch file (e.g.aaa.bat) which can take several paramters and runs fine as long as I enter the start command at the command prompt e.g

aaaa.bat -start -log

In order to avoid always having to enter manually this command I created a shortcut to this batch file and placed it in the SAME directory and added once the desired parameters. The shortcut properties look like now:

Target: D:\proj2\test2011\aaaa.bat -start -log
Start in: D:\proj2\test2011

This works fine as well. Now the problem comes: I want to make these batch file and its shortcut portable.

That means users should be abel to copy both files (batch + shortcut) on their computer in an indiviual different directory and be able to start the shortcutted batch file WITHOUT adjustments as well.

BUT this does not work because "Target" and "STarted in" most problably have a different path (e.g. C:\evalproj\task23\).

My first approaches to solve this problems were to omit the path like in:

Target: aaaa.bat -start -log
Start in: .

But this does not help. If I try to apply the settings above for the shortcut I got an error popup:

"The name aaa.bat' specified in the target box is not valid"

Hmm, how do I specify in the shortcut=SAME DIRECTORY AS CURRENT SHORTCUT FILE otherwise?

Target: .\aaaa.bat -start -log

does not work either. Are users really forced to modify the Target path parameter according to their execution directory?

Peter
 
hi

to be honest im really confused what you are trying to achieve here, what the BAT does or the acutal question in hand., if you want help writing a batch file and outputting commands then i can help since i write scripts.

if you can post such as, the batch file exectutes a command to delete in c:/etc etc or start a program in c:/ etc etc .. or if you mean that the batch file you have wants to work on mutli machines then we can change specific paths ie. c:/ to %systemroot% or instead of a set name of ADMIN to %username% as a generic.
 
Back
Top