Solved

VBScript To RunAs USER - GPUPDATE

Posted on 2009-05-08
1
1,263 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now