Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
budhax
- Posts: 63
- Joined: 09 Oct 2006 12:25
#1
Post
by budhax » 31 Oct 2006 05:04
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.
-
DosItHelp
- Expert
- Posts: 239
- Joined: 18 Feb 2006 19:54
#2
Post
by DosItHelp » 31 Oct 2006 20:44
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?
-
budhax
- Posts: 63
- Joined: 09 Oct 2006 12:25
#3
Post
by budhax » 05 Nov 2006 07:29
Thanks so much, it works perfectly