title: pyinstaller error: OSError: [WinError 6] The handle is invalid
body: <p>This File gets the wifi passwords using the terminal command <code>netsh wlan show profiles</code>
  I used pyinstaller to create a few .exe before and they worked jut fine.</p>
  <p>The Code:</p>
  <pre><code>import subprocess
  import time
  import sys
  import re
  
  command_output = subprocess.run([&quot;netsh&quot;, &quot;wlan&quot;, &quot;show&quot;, &quot;profiles&quot;], capture_output = True).stdout.decode()
  
  profile_names = (re.findall(&quot;All User Profile     : (.*)\r&quot;, command_output))
  
  wifi_list = []
  
  if len(profile_names) != 0:
      for name in profile_names:
          wifi_profile = {}
          profile_info = subprocess.run([&quot;netsh&quot;, &quot;wlan&quot;, &quot;show&quot;, &quot;profile&quot;, name], capture_output = True).stdout.decode()
          if re.search(&quot;Security key           : Absent&quot;, profile_info):
              continue
          else:
              wifi_profile[&quot;ssid&quot;] = name
              profile_info_pass = subprocess.run([&quot;netsh&quot;, &quot;wlan&quot;, &quot;show&quot;, &quot;profile&quot;, name, &quot;key=clear&quot;], capture_output = True).stdout.decode()
              password = re.search(&quot;Key Content            : (.*)\r&quot;, profile_info_pass)
              if password == None:
                  wifi_profile[&quot;password&quot;] = None
              else:
                  wifi_profile[&quot;password&quot;] = password[1]
              wifi_list.append(wifi_profile)
  
  for x in range(len(wifi_list)):
      print(wifi_list[x])
  
  time.sleep(5)
  print(&quot;No more WiFi Profiles Found&quot;)
  time.sleep(3)
  sys.exit()
  </code></pre>
  <p>This is the Error I get when Running the .exe:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;GetWiFiPassWord.py&quot;, line 6, in &lt;module&gt;
    File &quot;subprocess.py&quot;, line 453, in run
    File &quot;subprocess.py&quot;, line 709, in __init__
    File &quot;subprocess.py&quot;, line 1006, in _get_handles
  OSError: [WinError 6] The handle is invalid
  </code></pre>