# How can I execute a .bat file when Blender starts?

I have to start a postgresql server when blender starts. To start the server I use a .bat file I start manually.

I want to automatically start the server (execute the .bat) when Blender starts. I tried this script but it not working. ideas?

import subprocess
filepath="C:\Users\PORTABLE\Desktop\pgsql_binaire\pgsql\test.bat"
p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
stdout, stderr = p.communicate()

• Dont you need double slashes or forward slash? c:\\folder\\file or c:/folder/file – IAmNoone Jul 9 '15 at 14:55
• When I use \\ or / and I execute the script, Blender not responding! – logiquefloue Jul 9 '15 at 15:06
• do you start it and let it run in the background? check if postgresql has started. check this question for starting a process and letting it run in the background. stackoverflow.com/questions/1196074/… – IAmNoone Jul 9 '15 at 15:12

import bpy