How do I rewrite this .bat file code onto Python? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How do I rewrite this .bat file code onto Python? (/thread-22160.html) |
How do I rewrite this .bat file code onto Python? - SteampunkMaverick12 - Nov-01-2019 set APPDATA=%CD%\data bin\minecraft.exedon't ask why RE: How do I rewrite this .bat file code onto Python? - Larz60+ - Nov-01-2019 first, by giving it a try, and if unsuccessful then asking questions. RE: How do I rewrite this .bat file code onto Python? - SteampunkMaverick12 - Nov-02-2019 (Nov-01-2019, 05:03 PM)Larz60+ Wrote: first, by giving it a try,thing is ie already tried 2 methods using os and subprocess I found on reddit RE: How do I rewrite this .bat file code onto Python? - Axel_Erfurt - Nov-02-2019 show it. RE: How do I rewrite this .bat file code onto Python? - snippsat - Nov-02-2019 (Nov-02-2019, 05:28 PM)SteampunkMaverick12 Wrote: thing is ie already tried 2 methods using os and subprocess I found on redditAs mention you should show what you tired,it also help if understand what code dos set is setting environment variable for current session.%CD% get current working directory,in python os.getcwd() .As bin\minecraft.exe is on a new line means that running minecraft.exe with environment in set .So then it could be like this. import subprocess, os d = dict(os.environ) d['APPDATA'] = f'{os.getcwd()}\\data' subprocess.run(['bin\minecraft.exe'], env=d) |