Python Forum

Full Version: How do I rewrite this .bat file code onto Python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
set APPDATA=%CD%\data
bin\minecraft.exe
don't ask why
first, by giving it a try,
and if unsuccessful then asking questions.
(Nov-01-2019, 05:03 PM)Larz60+ Wrote: [ -> ]first, by giving it a try,
and if unsuccessful then asking questions.
thing is ie already tried 2 methods using os and subprocess I found on reddit
show it.
(Nov-02-2019, 05:28 PM)SteampunkMaverick12 Wrote: [ -> ]thing is ie already tried 2 methods using os and subprocess I found on reddit
As mention you should show what you tired,it also help if understand what code dos Wink
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)