On Thu, 4 Dec 2025 11:06:21 -0500 Em wrote:

>Two computers, both alike in dignity, in fair windows land...
>
>in Win10/Python 3.13 my program runs as well as can be expected. However, on
>my new computer Win11/Python 3.14.1 there is a peculiarity.
>
>On the new machine, when I click on the file name, it immediately dumps out.
>I go in with IDLE and it runs fine with no indication of any error.
>
>I believe this line is the culprit:
>Starter = open(HLYlog.txt", "w")
>
>Thoughts appreciated.

I asked claude.ai...

Question:  any reason this python statement works on windows10; but fails
on windows11 when called from cmd; yet works on both from IDLE:
open("file.txt","w")

This is an interesting permission/behavior difference between Windows
versions and execution contexts. Here are the most likely culprits: 

1. Controlled Folder Access (Windows Defender)

Windows 11 has more aggressive "Controlled Folder Access" settings by
default. When running from cmd.exe, Python might not be in the allowed
apps list, blocking write access to protected folders (like Documents,
Desktop, etc.).

Check: Windows Security → Virus & threat protection → Ransomware
protection → Controlled folder access 

2. Working Directory Differences

From cmd, Python's working directory is wherever cmd is currently located
(could be C:\Windows\System32 or your user folder). IDLE typically
defaults to a different location.

Try in cmd:

python -c "import os; print(os.getcwd())"

If it's trying to write to System32 or another protected location, that
would explain the failure. 

3. UAC/Permissions Changes

Windows 11 has stricter UAC enforcement. The cmd session might be running
with different privileges than IDLE.

Test: Right-click cmd → "Run as administrator" and try again.

4. Antivirus/Real-time Protection

Some antivirus software treats cmd-spawned processes differently than GUI
apps like IDLE.

What's the actual error message? That would narrow this down immediately:

    PermissionError: [Errno 13] → Permissions/Controlled Folder Access
    FileNotFoundError → Working directory issue
    Other errors → Different root cause

Quick diagnostic: Try open("C:\\Temp\\file.txt", "w") from cmd (assuming
C:\Temp exists) to see if it's directory-specific.

-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to