1
votes

I am trying to get python27 to execute a very simple bat file (this code is simplified/striped down to a single line). The bat file contains:

C:/Users/dave/Desktop/vlc-2.2.6/vlc.exe

the python code to create and run the bat file is

import subprocess
f = open('myfile.bat', 'w')
f.write('C:/Users/dave/Desktop/vlc-2.2.6/vlc.exe')
f.close()
subprocess.Popen('C:/Users/dave/Desktop/myfile.bat', stdout=subprocess.PIPE)

Running the python script using idle, vlc opens. Double clicking the bat file, vlc opens. Double clicking the python script the cmd window opens and closes instantly, vlc command is not executed

I have caught the error once by pressing the pause break button and it stated vlc is not a recognised internal or external command, obviously it is when the bat file is called via idle or by myself.

I am perplexed and new to this style of scripting.

Any adivce would be greatly appreciated.

Many thanks

Dave

1
Add some code to prevent the double-clicked script from exiting immediately, and copy-paste the exact error here. E.g., surround the Popen(...) with: try: subprocess.Popen(...); except Exception as e: print(e); input("Press RETURN to exit").alexis

1 Answers

0
votes

SOLVED well sort of

I decided to uninstall all python versions and reinstall python27 64bit.

Without restart;

The commands are being executed I only get 5 identical errors stating:

The process tried to write to a nonexistent pipe 

My code is obviously wrong!

But, vlc opens!