Solved

VBScript To RunAs USER - GPUPDATE

Posted on 2009-05-08
1
1,281 Views
Last Modified: 2012-06-27
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
Comment
Question by:Ryan Rood
1 Comment
 
LVL 1

Accepted Solution

by:
Ryan Rood earned 0 total points
ID: 24338559
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question