Python Forum
How do I rewrite this .bat file code onto Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I rewrite this .bat file code onto Python?
#1
set APPDATA=%CD%\data
bin\minecraft.exe
don't ask why
Reply
#2
first, by giving it a try,
and if unsuccessful then asking questions.
Reply
#3
(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
Reply
#4
show it.
Reply
#5
(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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with importing Python file in Visual Studio Code DXav 7 4,937 Jun-15-2022, 12:54 PM
Last Post: snippsat
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,353 Feb-13-2022, 07:13 PM
Last Post: menator01
  Optmized way to rewrite this very slow code liva28 0 1,472 Jul-18-2021, 12:16 PM
Last Post: liva28
Sad SyntaxError: from simple python example file from mind-monitor code (muse 2) warmcupoftea 4 2,753 Jul-16-2021, 02:51 PM
Last Post: warmcupoftea
  Request for Python code - Features extraction from JSON file (cuckoo) thinker 1 2,149 Apr-07-2021, 04:40 PM
Last Post: Larz60+
  Skeleton file export error Python Code pepapoha 4 3,428 Nov-17-2020, 02:06 AM
Last Post: pepapoha
  Find the realpath for a symlinked .pth file in itself with python code. hongyi 7 2,994 Apr-27-2020, 05:30 AM
Last Post: Larz60+
  Cleaner way to rewrite fakka 5 3,012 Dec-05-2019, 04:53 AM
Last Post: stullis
  Please suggest python code to format DNA sequence FASTA file rajamdade 4 3,118 Oct-24-2019, 04:36 AM
Last Post: rajamdade
  I need help! How to package python code with other component into an exe file?? Wendy 4 2,815 Jul-15-2019, 01:29 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020