def run_program(entry, path, parent): # noqa import re cmdline = entry_to_cmdline(entry, path) flags = win32con.CREATE_DEFAULT_ERROR_MODE | win32con.CREATE_NEW_PROCESS_GROUP if re.match(r'"[^"]+?(.bat|.cmd|.com)"', cmdline, flags=re.I): flags |= win32con.CREATE_NO_WINDOW console = ' (console)' else: flags |= win32con.DETACHED_PROCESS console = '' print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline)) try: with sanitize_env_vars(): process_handle, thread_handle, process_id, thread_id = CreateProcess( None, cmdline, None, None, False, flags, None, None, STARTUPINFO()) WaitForInputIdle(process_handle, 2000) except Exception as err: return error_dialog( parent, _('Failed to run'), _('Failed to run program, click "Show Details" for more information' ), det_msg='Command line: %r\n%s' % (cmdline, as_unicode(err)))
def run_program(entry, path, parent): # noqa cmdline = entry_to_cmdline(entry, path) print('Running Open With commandline:', repr(entry['cmdline']), ' |==> ', repr(cmdline)) try: with sanitize_env_vars(): process_handle, thread_handle, process_id, thread_id = CreateProcess( None, cmdline, None, None, False, win32con.CREATE_DEFAULT_ERROR_MODE | win32con.CREATE_NEW_PROCESS_GROUP | win32con.DETACHED_PROCESS, None, None, STARTUPINFO()) WaitForInputIdle(process_handle, 2000) except Exception as err: return error_dialog( parent, _('Failed to run'), _( 'Failed to run program, click "Show Details" for more information'), det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
def run_program(entry, path, parent): import subprocess cmdline = entry_to_cmdline(entry, path) print('Running Open With commandline:', repr(cmdline)) try: with sanitize_env_vars(): process = subprocess.Popen(cmdline) except Exception as err: return error_dialog( parent, _('Failed to run'), _( 'Failed to run program, click "Show Details" for more information'), det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err))) t = Thread(name='WaitProgram', target=process.wait) t.daemon = True t.start()
def run_program(entry, path, parent): import subprocess cmdline = entry_to_cmdline(entry, path) print('Running Open With commandline:', repr(cmdline)) try: with sanitize_env_vars(): process = subprocess.Popen(cmdline) except Exception as err: return error_dialog( parent, _('Failed to run'), _( 'Failed to run program, click "Show details" for more information'), det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err))) t = Thread(name='WaitProgram', target=process.wait) t.daemon = True t.start()
def run_program(entry, path, parent): # noqa import re cmdline = entry_to_cmdline(entry, path) flags = subprocess.CREATE_DEFAULT_ERROR_MODE | subprocess.CREATE_NEW_PROCESS_GROUP if re.match(r'"[^"]+?(.bat|.cmd|.com)"', cmdline, flags=re.I): flags |= subprocess.CREATE_NO_WINDOW console = ' (console)' else: flags |= subprocess.DETACHED_PROCESS console = '' print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline)) try: with sanitize_env_vars(): winutil.run_cmdline(cmdline, flags, 2000) except Exception as err: return error_dialog( parent, _('Failed to run'), _( 'Failed to run program, click "Show details" for more information'), det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
def run_program(entry, path, parent): # noqa import re cmdline = entry_to_cmdline(entry, path) flags = win32con.CREATE_DEFAULT_ERROR_MODE | win32con.CREATE_NEW_PROCESS_GROUP if re.match(r'"[^"]+?(.bat|.cmd|.com)"', cmdline, flags=re.I): flags |= win32con.CREATE_NO_WINDOW console = ' (console)' else: flags |= win32con.DETACHED_PROCESS console = '' print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline)) try: with sanitize_env_vars(): process_handle, thread_handle, process_id, thread_id = CreateProcess( None, cmdline, None, None, False, flags, None, None, STARTUPINFO()) WaitForInputIdle(process_handle, 2000) except Exception as err: return error_dialog( parent, _('Failed to run'), _( 'Failed to run program, click "Show Details" for more information'), det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))