[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1296
  • Last Modified:

VBScript To RunAs USER - GPUPDATE

Hi,

I am looking for a VBScript to runas another user (local admin) to start gpupdate/force as this specific user. I have not been able to find the code to do this. Script needs to be configurable with user/password.

Thanks,
Ryan
0
Ryan Rood
Asked:
Ryan Rood
1 Solution
 
Ryan RoodAuthor Commented:
Found a solution.
Set WshShell=WScript.CreateObject("WScript.Shell")
strCmd="C:\windows\system32\gpupdate.bat"
strUser="DOMAIN\USER"
strPass="PASSWORD"
set WshShell=CreateObject("WScript.Shell")
WshShell.Run "runas.exe" & " /u:" & strUser & " " & strCmd
WScript.Sleep 1000
WshShell.Sendkeys strPass & "~"

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now