On 12/7/2025 7:22 AM, Roel Schroeven wrote:
Op 7/12/2025 om 1:54 schreef Thomas Passin:
As I explained in my last post, that's because in Windows 11 when double-clicking, the working directory is the system's Windows directory, not the one your program is in.
Irrespective of anything else that's going on, that's not my experience. I just tried, and double-clicking a python script makes the directory that I have open in Explorer the current directory. I've seen the same not just with scripts but also with executables. I don't think this is the cause.

It *was* the case *on my system* when I tested the program under consideration. I included the output and it clearly showed that the working directory at launch was C:\WINDOWS\system32.

The situation about file associations in Windows 11 is complicated because there is the new mechanism, and the old one is still there, apparently, and they may not always work the same way.

By the "old" mechanism I mean the way that the associations were set up in the registry by specifying a logical name like Python.file for the .py extension, and having registry keys for the default program to use for Python.file types. You could display (or change, I think, though I never did) these associations from the command line with the programs assoc and ftype. For example, I used to be able to run this:

C:\Users\tom>ftype Python.file
Python.file="C:\Windows\py.exe" "%L" %*

Now I get this:

C:\Users\Tom>assoc .py
File association not found for extension .py

C:\Users\Tom>ftype Python.file
File type 'Python.file' not found or no open command associated with it.

The lack of such file associations in my registry is not limited to Python files. It's the same for Javascript and Java files (the only other ones I looked at). You are supposed to use the Settings/Default apps page to make changes now, but you can't change the launch arguments, or at least I don't know how.

I used to add or change the associations right in the registry when needed. The programs assoc and ftype still exist on my Win 11 system but they don't return anything, and the registry entries behind them aren't present any more.

I tend to launch the programs I use the most using <WIN>-R, and when needed I can modify the launch command used in the dialog that pops up. Most others I launch using a small batch file. I hardly ever launch any more by double clicking a bare file icon. So I could easily have missed a change like this in Windows's behavior.

At any rate, the OP has been making things harder by not following, or not following completely, the simple suggestions that have been made. He needs to find out what the working directory is when the program is run by double-clicking, or he has to make his program work no matter what the startup directory is. Sample code for all that has been posted in this thread.
--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to