my script has to open different kind of scripts (.exe, .py, .c, etc..) and to reach this goal I use these two instructions:
- os.chdir(FOLDER_PATH)
- os.system("start "+SCRIPT_NAME)
the code works, but it shows the console window whenever os.system("start "+SCRIPT_NAME) is used. to hide it, I read on internet that I have to use the subprocess module. I tried to use these commands but they don't work:
C:\test
λ ls -l
total 16
-rw-r--r-- 1 Admin 197121 13721 Oct 19 00:44 test.py
C:\test
λ python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import subprocess
>>> from subprocess import CREATE_NO_WINDOW
>>>
>>> subprocess.call("test.py", creationflags=CREATE_NO_WINDOW)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 193] %1 is not a valid Win32 application
>>>
how can I solve the issue?
 
    