Hi
I am new to IT.
I have a batch file named myfile.bat placed at D:\myfolder1\
I want to know batch script which can identify the directory from which this batch file is currently executing even if the file has been moved to a new location.
is it possible? if yes then how?
The OS will first look at the current directory for myfile.bat
If myfile.bat is not in the current directory, the OS will use the official search path to fo find myfile.bat
C:\Windows\system32>path /?
Displays or sets a search path for executable files.
PATH [[drive:]path[;...][;%PATH%]
PATH ;
Type PATH without parameters to display the current path.
Including %PATH% in the new path setting causes the old path to be
appended to the new setting.
C:\Windows\system32>
C:\>cd \
C:\>dir /s myfile.bat
rem the above code will find all locations of myfile.bat on your computer