Saved Bookmarks
| 1. |
Solve : batch help filename? |
|
Answer» How WOULD I find out the name of the batch file that's running the current command? %1-9 are the parameters paseed to a batch file. More exactly, it is the command line that called it. If this is myname.bat: Code: [Select]@echo off echo %0 If you are in the same folder and you type myname.bat, you will see "myname.bat" echoed to the screen. If you type "myname" it will echo "myname". This behaviour also occurs if you save it to a folder on your PATH and call it by either of these two methods. If you type the WHOLE path e.g. "C:\batch\myname.bat", then that is what %0 will be. If you open the folder in Windows Explorer, and double click on the batch file's ICON, %0 contains the full drive, path, name and extension, surrounded by quotes. To avoid this ambiguity, you can get the name, extension, path and drive by using the %~d0, %~dp0, %~nx0 etc variable modifers DESCRIBED in the FOR documentation. For example the drive LETTER, path, name and extension is %~dpnx0 |
|