0
import subprocess
current_machine_id = subprocess.check_output('wmic csproduct get uuid').decode().split('\n')[1].strip()
print(current_machine_id)

Running this code with vscode is working fine, But when i create exe file using pyinstaller i get error like this:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
  File "subprocess.py", line 411, in check_output
  File "subprocess.py", line 488, in run
  File "subprocess.py", line 753, in __init__
  File "subprocess.py", line 1054, in _get_handles
OSError: [WinError 6] The handle is invalid

Any solution will appreciated

  • Your code is working fine for me, what do you mean `when i create exe file using pyinstaller`? Please add the exact command line arguments you are running. – Jortega Nov 13 '21 at 17:28
  • "pyinstaller --onefile -w test.py" I use this command to create exe file from python script where test.py contains the above code. the exe created successfully but when i run the exe file I get this error. – Monjurul Majid Nov 13 '21 at 18:17
  • Does this answer your question? [pyinstaller error: OSError: \[WinError 6\] The handle is invalid](https://stackoverflow.com/questions/69425010/pyinstaller-error-oserror-winerror-6-the-handle-is-invalid) – Maurice Meyer Nov 14 '21 at 10:11
  • Problem solved, When I use "pyinstaller --onefile -w script.py" it throws this error. But when I use "pyinstaller --onefile script.py" it works perfectly. – Monjurul Majid Nov 16 '21 at 15:41

1 Answers1

0

How about if you try to add:

stdin=subprocess.DEVNULL

Eugenio
  • 133
  • 7