2

I want to execute an exe file in script which requires command like this in commandline C:\pathtotool.exe -2 c:\data .

how can i do this in python in windows. Os.system does not work

kalyani gandhi
  • 31
  • 1
  • 1
  • 2

1 Answers1

3
import subprocess

# Call your exe
subprocess.call('C:\pathtotool.exe -2 c:\data ')

# if you want to print output 
p = subprocess.check_output('C:\pathtotool.exe -2 c:\data ')
print p

or

import os
os.system(start 'C:\pathtotool.exe -2 c:\data ')
Rajiv Sharma
  • 6,746
  • 1
  • 52
  • 54