title: PowerShell Commands Will Not Respond Or Throws Error Using subprocess.run() in PyQt5
body: <p>For two days now I have been trying to open the Control Panel Mail (Microsoft Outlook) Control Panel Item using Python <code>subprocess.run()</code> in a PyQt5 application.</p>
  <p>I have narrowed it down to the two commands below:</p>
  <pre><code> 1.) `control mlcfg32.cpl`
  
   2.) `Show-ControlPanelItem *Mail (Microsoft Outlook)`
  </code></pre>
  <p>In PowerShell, command 1.) does nothing, no error, no anything. Command 2.) works fine. The Mail Setup applet open right up.</p>
  <p>However, when trying to open the Main Setup applet in the PyQt5 application, I am not getting the same result. I have tried the two lines below:</p>
  <pre><code> 1.) `subprocess.run([&quot;Powersehll.exe&quot;, &quot;Show-ControlPanelItem&quot;, &quot;*Mail (Microsoft Outlook)&quot;], shell=True)`
  
   2.) `subprocess.run([&quot;Powershell.exe&quot;, &quot;control&quot;, &quot;mlcfg32.cpl&quot;], shell=True)`
  </code></pre>
  <p>Command 1.) gives the following error message:</p>
  <pre><code>Microsoft : The term 'Microsoft' is not recognized as the name of a cmdlet, function, script file, or operable 
  program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
  At line:1 char:30
  + Show-ControlPanelItem *Mail (Microsoft Outlook)
  +                              ~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (Microsoft:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
   
  
  Process finished with exit code 0
  </code></pre>
  <p>Command 2.) does not open the Mail Setup applet, nor does it throw an error. It does absolutely nothing.</p>
  <p>In File Explorer, I located the MLCFG32.CPL file and it does its job, opening the Mail Setup applet when the file is Double-clicked.</p>
  <p><a href="https://i.stack.imgur.com/rl99y.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  <p>In addition to the commands listed above, I have also tried,</p>
  <pre><code> - `subprocess.run([&quot;PowerShell.exe&quot;, &quot;-ExecutionPolicy&quot;, &quot;unrestricted&quot;, &quot;Show-ControlPanelItem&quot;, &quot;*Mail (Microsoft Outlook)&quot;], shell=True)`
  </code></pre>
  <p>From the PyQt5 application, nothing has worked. I just have a button that's a dud. Could someone please help me with this problem?</p>
  <p>The code in its entirety is shown below:</p>
  <pre><code>from PyQt5.QtWidgets import *
  from PyQt5 import QtGui
  import subprocess
  import sys
  
  
  class Window(QWidget):
      def __init__(self):
          super().__init__()
          self.setWindowTitle(&quot;Open Control Panel Mail (Microsoft Outlook) Applet&quot;)
          self.setWindowIcon(QtGui.QIcon(&quot;IMAGES I/Cube.png&quot;))
          self.setStyleSheet(&quot;background-color: #FFFFFF;&quot;)
          self.resize(450, 80)
          self.gui()
  
      def gui(self):
          self.widgets()
          self.center_window()
          self.show()
  
      def widgets(self):
          mail_btn = QPushButton(&quot;Mail (Microsoft Outlook)&quot;, self)
          mail_btn.setStyleSheet(&quot;font-size: 12pt; background-color: #B4D6FE;&quot;)
          mail_btn.move(140, 25)
          mail_btn.clicked.connect(self.open_mail_applet)
  
      def open_mail_applet(self):
          subprocess.run([&quot;Powershell.exe&quot;, &quot;Show-ControlPanelItem&quot;, &quot;*Mail (Microsoft Outlook)&quot;], shell=True)
          # subprocess.run([&quot;Powershell.exe&quot;, &quot;control&quot;, &quot;mlcfg32.cpl&quot;], shell=True)
  
      def center_window(self):
          qr = self.frameGeometry()
          cp = QDesktopWidget().availableGeometry().center()
          qr.moveCenter(cp)
          self.move(qr.topLeft())
  
  
  def main():
      App = QApplication(sys.argv)
      window = Window()
      sys.exit(App.exec_())
  
  
  if __name__ == '__main__':
      main()
  </code></pre>