Page 1 of 1

Different current folder for DoubleClick and DragAndDrop

Posted: 31 Oct 2006 05:04
by budhax
Hello,
here is my script dir.bat :

Code: Select all

dir
pause
:: and other command lines


If you double click this file (dir.bat) you get the file listing of the current folder (the folder where dir.bat is located).
Fine. :)

But, if you drag and drop a file on dir.bat, you get allays the file listing of the %USERPROFILE% folder :(

How to get (how to go to) the current folder if you drag and drop a file on dir.bat ?

Thanks in advance.

Posted: 31 Oct 2006 20:44
by DosItHelp
budax,

You can change the current path to the directory of the batch file like this:

cd /d "%~dp0"
dir
pause


%~dp0 - resolves to the drive and path of the batch file itself.

DOS IT HELP? :wink:

Posted: 05 Nov 2006 07:29
by budhax
Thanks so much, it works perfectly ;-)