Skip to content
Tech News
← Back to articles

Windows Explorer sets current directory on double-click, batch files don't

read original more articles
GoKawiil Brief

A developer reported that a program failed with an error when launched from a batch file but ran fine when double-clicked in Windows Explorer. Microsoft's Raymond Chen explained that Explorer automatically sets the current working directory to the folder containing the launched file, while a batch file calling the program by full path does not change the directory at all. The customer fixed the issue by using pushd and popd commands to set and restore the working directory within the batch file.

Why It Matters

GoKawiil's interpretation of the reporting above, not reported fact.

The explanation highlights a subtle but common pitfall in Windows scripting: programs that rely on finding ancillary files relative to the current directory can break silently depending on how they are launched. This suggests developers writing batch files or automation scripts should explicitly manage working directories rather than assume Explorer-like behavior.

Key Takeaways

Source: devblogs.microsoft.com — Raymond Chen, 2026-10-26

Published there as: “Why a program doesn't work when run from a batch file, but works when clicked”

Read the original report → The summary and analysis above are GoKawiil's own, written from reporting by the source above. Facts and quotes belong to the original publisher.