title: Run Powershell command in macro as Admin (Elevated)
body: <p>I have written some code that runs in a macro. Somehow the code runs the Powershell command (which is calc.exe), so specifically, I want to run the command as admin (elevated)? Can someone help me?</p>
  
  <p>This is the code</p>
  
  <pre><code>Sub Auto_Open()
          o
  End Sub
  
  Sub AutoOpen()
          o
  End Sub
  
  Sub Document_Open()
          o
  End Sub
  
  Public Function o() As Variant
          Dim fSfv As String
          fSfv = "powershell calc.exe"
          Const HIDDEN_WINDOW = 0
          strComputer = "."
          Set objWMIService = GetObject("winmgmts:\\" &amp; strComputer &amp; "\root\cimv2")
          Set objStartup = objWMIService.Get("Win32_ProcessStartup")
          Set objConfig = objStartup.SpawnInstance_
          objConfig.ShowWindow = HIDDEN_WINDOW
          Set objProcess = GetObject("winmgmts:\\" &amp; strComputer &amp; "\root\cimv2:Win32_Process")
          objProcess.Create fSfv, Null, objConfig, intProcessID
  End Function
  </code></pre>