'Batch file %~dp0 don't work inside zip file
I had a batch file with a code:
@echo off
type "%~dp0\ascii.txt"
PAUSE
Basically, it opens the ascii.txt file and echo it in the batch file. It does work as it should when I run the batch file in a folder. However, when I zip the folder and run the batch file, it creates a temp rar folder in the local temps folder excluding the ascii.txt inside, and became the current directory of the batch file.
I have confirmed this by echoing out the %~dp0 inside a the zip file and it shows the directory of a new created rar file.
1st Launch:
C:\<path>\Temp\Rar$DIa39068.14007
2nd Launch: C:\<path>\Temp\Rar$DIa39068.18707
3nd Launch: C:\<path>\Temp\Rar$DIa39068.19757
As you can see, each time I launch the batch file, the directory changes into a newly created one. and that directory only includes the batch file alone, but not other the files.
Is there really no way to load the current directory instead of magically creating a new empty one?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|