Launch Windows executable from python
#1
Hi @ all,

I tried to write a python script that launches a windows applicatio ( MakeMKV )

My code is:
Code:
import xbmc
import sys,os,xbmcaddon,xbmcgui,shutil,re

# Script constants
__scriptname__ = "MakeMKV"
__author__     = "mad-max"
__version__    = "0.1"



run = XBMC.System.Exec("C:\Program Files (x86)\MakeMKV\makemkv.exe")

run()

The error message in the log is:

Code:
ERROR: Traceback (most recent call last):
                                              File "C:\Users\max\AppData\Roaming\XBMC\addons\script.DVBViewer\default.py", line 11, in ?
                                                run = XBMC.System.Exec("C:\Program Files (x86)\MakeMKV\makemkv.exe")
                                            NameError: name 'XBMC' is not defined

import xbmc is set in the script!
Any idea why this is not working?
Other ways to launch the exe?

Thanks for your help in advance.

cheers,
mad-max
- - - Tribute to Metallica - - -
If I managed to help you, please click my reputation
Reply
#2
To run a built in function from python, you will need to use the 'executebuiltin()' function from the xbmc module

I also believe you will need to use two backslashes instead of one, as python interprets the single backslash as an escape character.

Code:
xbmc.executebuiltin('XBMC.System.Exec("C:\\Program Files (x86)\\MakeMKV\\makemkv.exe")')


mad-max Wrote:Hi @ all,

I tried to write a python script that launches a windows applicatio ( MakeMKV )

My code is:
Code:
import xbmc
import sys,os,xbmcaddon,xbmcgui,shutil,re

# Script constants
__scriptname__ = "MakeMKV"
__author__     = "mad-max"
__version__    = "0.1"



run = XBMC.System.Exec("C:\Program Files (x86)\MakeMKV\makemkv.exe")

run()

The error message in the log is:

Code:
ERROR: Traceback (most recent call last):
                                              File "C:\Users\max\AppData\Roaming\XBMC\addons\script.DVBViewer\default.py", line 11, in ?
                                                run = XBMC.System.Exec("C:\Program Files (x86)\MakeMKV\makemkv.exe")
                                            NameError: name 'XBMC' is not defined

import xbmc is set in the script!
Any idea why this is not working?
Other ways to launch the exe?

Thanks for your help in advance.

cheers,
mad-max
Reply
#3
Hi giftie,

thanks for the hint...I didn´t get it to work, so I just
start the file with "os.startfile()"...

Thanks anyway...
- - - Tribute to Metallica - - -
If I managed to help you, please click my reputation
Reply

Logout Mark Read Team Forum Stats Members Help
Launch Windows executable from python0