title: How to restart graphics drivers with Powershell or C# without admin privileges
body: <p>I need to restart the graphics driver automated on computers which users should not have admin privileges. My options to archive this is using powershell or C# code called from powershell.</p>
  
  <p>The simplest way to restart the graphics driver is mentioned in this Question: 
  <a href="https://stackoverflow.com/questions/27599287/powershell-disable-and-enable-a-driver">PowerShell disable and enable a driver</a></p>
  
  <pre><code> $d = Get-PnpDevice| where {$_.class -like "Display*"}
   $d  | Disable-PnpDevice -Confirm:$false
   $d  | Enable-PnpDevice -Confirm:$false
  </code></pre>
  
  <p>But I cant use it because it needs admin privileges on executing.
  The Second and better approach is to use the win + ctrl + shift + b Hotkey which doesnt need admin rights.
  I have found a good example how to press the win key in a combination on this site: <a href="https://github.com/stefanstranger/PowerShell/blob/master/WinKeys.ps1" rel="nofollow noreferrer">https://github.com/stefanstranger/PowerShell/blob/master/WinKeys.ps1</a></p>
  
  <p>And builded it to my needs. </p>
  
  <p>My actually code is this:</p>
  
  <pre><code>    $source = @"
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Runtime.InteropServices;
      using System.Windows.Forms;
      namespace KeyboardSend
      {
          public class KeyboardSend
          {
              [DllImport("user32.dll")]
              public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
              private const int KEYEVENTF_EXTENDEDKEY = 1;
              private const int KEYEVENTF_KEYUP = 2;
              public static void KeyDown(Keys vKey)
              {
                  keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY, 0);
              }
              public static void KeyUp(Keys vKey)
              {
                  keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
              }
          }
      }
      "@
      Add-Type -TypeDefinition $source -ReferencedAssemblies "System.Windows.Forms"
  
      Function Win($Key, $Key2, $Key3)
      {
          [KeyboardSend.KeyboardSend]::KeyDown("LWin")
          [KeyboardSend.KeyboardSend]::KeyDown("$Key")
          [KeyboardSend.KeyboardSend]::KeyDown("$Key2")
          [KeyboardSend.KeyboardSend]::KeyDown("$Key3")
          [KeyboardSend.KeyboardSend]::KeyUp("LWin")
          [KeyboardSend.KeyboardSend]::KeyUp("$Key")
          [KeyboardSend.KeyboardSend]::KeyUp("$Key2")
          [KeyboardSend.KeyboardSend]::KeyUp("$Key3")
      }
      Win 163 161 66
  
  # 163 = ctrl key
  # 161 = shift key
  # 66 = b key
  </code></pre>
  
  <p>If I try other combinations beside like win + e for opening the explorer it just works fine. But if i want to type win + ctrl + shift + b in, it just do nothing and closes itself without a error message.</p>
  
  <p>Am I missing something?</p>