Reputation: 21
It's saying that the quote ' after test.bat and before ) is invalid syntax in the first system_call(). . How can I fix this? I don't seem to be doing anything wrong. (I am new to Python.)
import os
import subprocess
def system_call(command):
r = subprocess.call("cmd.exe /K " + "%s" % command,shell=False)
print (r)
system_call(r 'echo “@ECHO OFF\nECHO.\nECHO\n This is a batch file\nECHO.\nPAUSE\nCLS\nEXIT” > C:\Users\User\Desktop\test.bat ')
system_call('cd C:\Users\User\Desktop\ ')
system_call('test')
Upvotes: 2
Views: 57
Reputation: 11
Try changing the quotation marks surrounding this section of code,
“@ECHO OFF\nECHO.\nECHO\n This is a batch file\nECHO.\nPAUSE\nCLS\nEXIT”
Change to
"@ECHO OFF\nECHO.\nECHO\n This is a batch file\nECHO.\nPAUSE\nCLS\nEXIT"
Notice how the original quotes(your code) has a curve to them where as I replaced those with straight, non fancy quotations. In my experience the fancy ones can, at times, cause issues.
P.S. This is my first answer here on Stack over flow, so I'm taking a stab at it :) hope it helps
Upvotes: 1