Batch File Program Failures: It's the Current Directory
Original source
Why a program doesn't work when run from a batch file, but works when clicked
Hacker News →A customer’s program worked fine when double-clicked in Explorer but failed when executed from a batch file. The suspected cause was the current directory not being set correctly. When you double-click a file in Explorer, the system automatically sets the current directory to that file’s location, allowing programs to find ancillary files in the same directory. The author hypothesized that the customer’s program looked for supporting files relative to its current directory, but the batch file ran it using its full path without adjusting the current directory.
The customer confirmed that explicitly setting the directory resolved the issue, using pushd to change the directory and popd to restore it afterward. As an alternative diagnostic step, the author mentioned checking for a custom entry under App Paths that might request additional directories be added to the PATH environment variable.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.