-1

So when i try to open a .bat file:

Traceback (most recent call last):
  File "accorddownload.py", line 31, in <module>
    subprocess.run(["Tools\aAIvwb.bat"], creationflags=0x08000000)
  File "C:\Program Files\Python37\lib\subprocess.py", line 472, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Program Files\Python37\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files\Python37\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

I am running it using

subprocess.run(["tools\aAIvwb.bat"], creationflags=0x08000000)

but the thing is I checked the location 20 times and keep trying to fix, but the same thing is happening. Here is file structure

AB
|
|--Tools--|
|         |--aaitp.bat
|         |--aAIvwb.bat
|         |--mdfa.bat
|
|--basefile.py

EDIT 1: The current working directory NEVER changes throughout the file

1 Answers1

0

I am suspicious of \ escaping. Have you considered calling like this:

subprocess.run([r"tools\aAIvwb.bat"], creationflags=0x08000000)

Note that I put an 'r' before the double quote.

Sean Suchter
  • 328
  • 1
  • 6