I did this, called the set command before and after the batik, and compared the result. If you need only after, then the code will be easier. Parsing the result of the set command is conveniently done by the ini-file parser, adding some section name to the beginning, as a result, the code is:
_CMD = "@echo off&echo [BEFORE]&set&echo *!*!*&{}&echo *!*!*&echo [AFTER]&set" x = subprocess.check_output(_CMD.format(batFile), shell=True).decode('cp1251') # ΡΠ±ΠΈΡΠ°Π΅ΠΌ ΡΡΠ΅Π΄Π½ΠΈΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ Π²ΡΠ²ΠΎΠ΄ Π±Π°ΡΠΈΠΊΠ° x = ''.join(x.split('*!*!*')[::2]) conf = configparser.ConfigParser() conf.read_string(x) da, db = dict(conf.items('AFTER')), dict(conf.items('BEFORE'))
Next, compare the da and db dictionaries and find out which environment variables have been changed in batik.