A Windows program that fails when launched from a batch file but works when opened by double-clicking may be relying on its current working directory. Explorer sets that directory to the folder containing the selected file, including when the user double-clicks the program’s executable. A batch file, by contrast, can start the same executable by its full path while leaving the working directory somewhere else. Programs that search the current directory for related files - such as configuration files, dictionaries, or other supporting data - may then be unable to find what they need and display an error.
The practical fix is to make the batch file change to the program’s directory before launching it, so the program runs with the same working-directory context it gets from Explorer. In the reported case, using `pushd` to enter the directory and `popd` afterward to restore the previous one resolved the problem. This distinction matters because specifying an executable’s full path does not automatically change the current directory to that executable’s location. If matching the working directory does not solve the issue, another possibility is that the program uses a custom Windows App Paths entry to add extra directories to its `PATH` when launched; that was suggested as a secondary diagnostic, though it was not needed in this case.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.