0

My goal: to run a file hello.py on my %PATH% when I write hello.

What I've done:

  • Made sure .py is part of PATHEXT.
C:\Windows\System32>echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYZ;.PYW
  • Made sure .py is associated with the ftype Python.File and that Python.File is associated with my Python installation.
C:\Windows\System32>ftype | findstr -i python
Python.File="C:/Users/gal/scoop/apps/python311/current/python.exe" "%1" %*

C:\Windows\System32>assoc .py
.py=Python.File
  • Made sure hello.py is on my %PATH% and that it executes correctly when I manually specify the Python executable, including taking arguments.
C:\Windows\System32>where hello
c:\path\hello.py

C:\Windows\System32>C:\Users\gal\scoop\apps\python311\current\python.exe c:\path\hello.py George Elaine
Hello, George and Elaine

Based on everything I'm reading this should be enough for it to work, but when I run hello.py or hello I get "Access is denied".

What am I doing wrong?

2
  • Does the file have 'Execute' permission granted? What does icacls show about it? Commented Aug 16, 2023 at 7:05
  • @u1686_grawity icacls shows that it BUILTIN\Administrators:(I)(F), NT AUTHORITY\SYSTEM:(I)(F), BUILTIN\Users:(I)(RX), NT AUTHORITY\Authenticated Users:(I)(M). Commented Aug 16, 2023 at 7:23

0

You must log in to answer this question.

Browse other questions tagged .