I am thinking about associating a file type extension to a batch script (.foo), so when double-clicking a file with .foo extension, this script will execute. The point is I do not know if there is a way to tell the script the path of the "executed" file (ie, which variable, if any, holds the path of the double clicked file).
Thank you.
The executed file is passed as first argument to the script. A simple example will show. Create a batchfile (for example foo_command.cmd) which contains:
echo %* > %~dpn0.log
Execute your desired filetype and connect it to the batchfile. This will write a file named foo_command.log (in the directory of foo_command.cmd) which contains all arguments passed to the script. You will see, it is the full path of the executed File.
In general the variable %1 in the script holds the path and there are no other variables set by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With