I have python installed on a school computer, but whenever I reboot, it of course loses the file associations and such. I have been building a batch file to try help me work around this problem, but I am stuck on the ftype command.
assoc .py=PythonFile
ftype PythonFile="H:\profile\programs\Python34\python.exe" "%1" "%*"
something is going wrong, because when I open a python file I get the error: H:\\profile\\programs\\Python34\\python.exe: can't find '__main__' module in ''
I dont understand this. I tried %0 in the ftype command but I think it associated python file with the batch file itself, because when I ran any python file, I got
File "init.cmd", line 1
@echo off
^
SyntaxError: invalid syntax
by the way, I read this answer. it didnt help. Simple ftype command not working
(if there is an alternative in powershell, I am open! :) thank you in advance!
happy holidays!
The %
character has special meaning inside batch files, so you need to "escape" them by using double %%
:
@echo off
assoc .py=PythonFile
ftype PythonFile="H:\profile\programs\Python34\python.exe" "%%1" "%%*"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.