Why a program doesn't work when run from a batch file, but works when clicked
Web page · https://devblogs.microsoft.com/oldnewthing/20261026-00?p=112797%2F
First seen by Oriel on .
AI summary
The post explains that a program launched from a batch file may fail because its current directory differs from the directory Explorer sets when the program is double-clicked.
- Explorer sets the current directory to the directory containing the double-clicked file, including when that file is an .exe.
- Programs that locate ancillary files relative to the current directory can fail when a batch file launches them from elsewhere.
- The customer fixed the issue by using pushd to change to the program's directory and popd to restore the original directory.
- As a secondary possibility, the post suggests checking whether an App Paths entry adds directories to PATH when the program runs.
#windows #batch files #current directory #app paths
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Hacker News: 140, latest observation ; +117 over observed period since
Comments
Comment count reported by the source.
- Hacker News: 83, latest observation ; +83 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Hacker News | 50251070 | https://devblogs.microsoft.com/oldnewthing/20261026-00/?p=112797/ Read discussion |