Op 7/12/2025 om 15:46 schreef Thomas Passin:
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.
Indeed, clearly there are differences between different installations.
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.
My Windows 11 still shows
C:\Users\Roel Schroeven>ftype Python.file
Python.file="C:\Windows\py.exe" "%L" %*
So yeah, there are differences, and I have to admit I'm not familiar
with how those things work.
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.
I completely agree. Yes, it can be frustrating when something that has
always worked doesn't work anymore. But it seems OP prefers to only
complain about it instead of trying to find the exact cause and/or a
solution, despite lots of suggestions in this thread.
--
"The major problem—one of the major problems, for there are several—one of the
many major problems with governing people is that of whom you get to do it; or
rather of who manages to get people to let them do it to them.
To summarize: it is a well-known fact that those people who must want to rule
people are, ipso facto, those least suited to do it.
To summarize the summary: anyone who is capable of getting themselves made
President should on no account be allowed to do the job."
-- Douglas Adams, The Restaurant at the End of the Universe
--
https://mail.python.org/mailman3//lists/python-list.python.org