Here is the code:
# -*- coding: utf-8 -*- import subprocess import argparse parser = argparse.ArgumentParser(description='Shell execute') parser.add_argument('-c', help = 'command') parser.add_argument('-a', help = 'args') args = parser.parse_args() command = args.c args = args.a def launchWithoutConsole(command, args): startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW return subprocess.Popen([command] + args, startupinfo=startupinfo).wait() try: launchWithoutConsole(command, args) except TypeError: exit() Then I’ll address it like this: python shellexlex.py -c help -a <here are the arguments>
I can't figure out how to pass in -a 2 or more arguments.
PS Here's how to call it turned out in code, but I need python shellex execution.py -c help -a <here arguments>
launchWithoutConsole("help", [">","filename.txt"])