0

I'm running several portable apps from my python app.

Consider the following code:

import win32com.shell.shell as w32shell
import os
import sys
import win32process as process

PORTABLE_APP_LOCATION = "C:\\Windows\\System32\\calc.exe"

#This function runs a portable application:
def runPortable():
    try:
        startObj = process.STARTUPINFO()
        process.CreateProcess(PORTABLE_APP_LOCATION,None,None,None,8,8,None,None,startObj)
        # OR
        #w32shell.ShellExecuteEx(lpFile=PORTABLE_APP_LOCATION)
    except:
        print(sys.exc_info()[0])
runPortable()

1) Should I expect any differences in the execution of this code from pythonw or python ?

2) If I change PORTABLE_APP_LOCATION to the path to a portable version of CDBurnerXP and use the ShellExecuteEx option instead of CreateProcess, I see the process is started on Windows Task Manager but the actual window of the app isn't visible. This doesn't happen with other EXEs such as a portable version of GIMP that do show up after being ran. I assume this difference comes from a property of the executables. Anybody knows what's causing this?

3) Under what terms does Windows prompts the "Are you sure you want to run this EXE"? I believe CDBurnerXP is signed with a certificate but still sometimes Windows pops this question when trying to run this EXE from within python.

Thanks a lot.

2 Answers 2

1

About Your first question , you should pay attention that when executing python code using pythonw.exe runtime , your sys.stdout buffer is limited to 4096 Bytes and when overflowed will throw an IOError wich you will not see because the code is running windowless .

Sign up to request clarification or add additional context in comments.

Comments

0

I am a newbie in this field. May be this can help you

use subprocess.call, more info here:

import subprocess
subprocess.call(["C:\\temp\\calc.exe"])

or

import os
os.system('"C:/Windows/System32/notepad.exe"')

i hope it helps you...

1 Comment

I am aware of other options to execute files like os.system and subprocess.call.. This isn't what I asked :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.