I use simple command
import os
os.system("set Var=test")
print("echo %Var%")
os.system("set /P Var=<test2.txt")
print("echo %Var%")
but it can't set batch file variable Var? How to set batch variable from python?
Thank you.
I use simple command
import os
os.system("set Var=test")
print("echo %Var%")
os.system("set /P Var=<test2.txt")
print("echo %Var%")
but it can't set batch file variable Var? How to set batch variable from python?
Thank you.
2 ways you could do this.
The first and most easy is to just run the echo command from os:
import os
os.system('set Var="test"\necho %Var%')
This will print your variable to the python command line
or you could write it to a file the run the file:
import os
with open("file.bat", "w") as wFile:
wFile.write('set Var="test"\necho %Var%')
os.system("file.bat")
ItzTheDodo.
EDITS: Updated examples