title: Pass Credentials to WMI Call in VBScript
body: <p>I have VBScript inside a HTA getting the ping status from a local WMI call.. I also have a function to get the last reboot time of the remote pc..</p>
  
  <pre><code>Function GetReboot(strComputer)
      Set objWMIService = GetObject _
          ("winmgmts:\\" &amp; strComputer &amp; "\root\cimv2")
      Set colOperatingSystems = objWMIService.ExecQuery _
          ("Select * from Win32_OperatingSystem")
      For Each objOS in colOperatingSystems
          dtmBootup = objOS.LastBootUpTime
          dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
          dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
          Wscript.Echo dtmSystemUptime
      Next
      GetReboot = dtmLastbootupTime
  End Function
  </code></pre>
  
  <p>That is roughly what it is, obviously i declare the variables and have another date function etc..</p>
  
  <p>This works if I WMI call "localhost" as I am a local admin.. however when doing the WMI call to a remote server this only works if I am logged in to my local machine with an AD admin account.</p>
  
  <p>Is there a way I can prompt the user for a username and password and then pass that to the WMI call so it works as anyone just with the admin details?</p>