hop of those help? Your initial batfile.close() call is unnecessary: the with block ensures that the file is closed when exiting the block. However, your later loop opens a new handle to the file on each pass through the loop and never closes them. You might consider rewriting your loop to something like:
with open("kill.bat", "a") as newbatfile:
for line in processlist:
newdata = line.replace("\n", "")
seems to work fine You can try this approach [NOT TESTED] : From batch1.bat, call batch2.bat and wait for it to terminate. Once it is terminated, use TASKKILL to kill the process associated with your game.
This might help you write takes one argument, which must be a string. It doesn't take multiple arguments like print, and it doesn't add a line terminator. If you want the behavior of print, there's a "print to file" option:
print >>whateverfile, stuff, to, print
print(stuff, to, print, out=whateverfile)
Created Batch file instantly closes without performing the written code
I wish this helpful for you Use "C:\Users\Angelo Hoft\PyProjects\hello.bat" as your command. Since the command contains a space, cmd will interpret the command you entered as C:\Users\Angelo with an argument of Hoft\PyProjects\hello.bat. Since C:\Users\Angelo is not an executable file, cmd duly reports this. Quoting the command tells cmd that the space is part of the string, not a separator between strings.