Problem setting up new laptop

I’ve never had this happen before. My old laptop is WIndows 10 Home and the new one is Windows 11 Home. I have a number of python scripts in D:\Utils that I can run from anywhere by typing the file name with no extension. While I can do the same on the new laptop, the scripts now do not recognize command line parameters. If I run the scripts by first typing ‘python’ then adding the script I can get access to the parameters, however if I do this then I always have to fully qualify the script name. It shouldn’t work this way. Can anyone suggest how to fix this? Obviously I have added .py and .pyw to %PATHEXT%. I suspect this is merely a “senior” moment and I have just forgotten something trivial.

D:>type test.py
import sys

print(f’{len(sys.argv)=}‘)
print(f’{sys.argv=}')
D:>
D:>
D:>
D:>test
len(sys.argv)=1
sys.argv=[‘D:\test.py’]

D:>
D:>
D:>
D:>test a b c
len(sys.argv)=1
sys.argv=[‘D:\test.py’]

D:>python test.py a b c
len(sys.argv)=4
sys.argv=[‘test.py’, ‘a’, ‘b’, ‘c’]

The file association is configured wrong. Right-click a “.py” file. Select “open with” → “choose another app”. In the open-with dialog, select the “Python” icon with a rocket on it, and enable “Always use this app to open .py files”.

Maybe at some point you used the “Look for another app on this PC” option and manually browsed for “python.exe” or “py.exe”. This creates an automatic file association that doesn’t support command-line arguments.

2 Likes

That did it. Thanks.

I believe that’s exactly what happened. Just out of curiosity, when I select the “rocket” app, what executable am I associating with?

1 Like