Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PSEXEC script command to force gpupdate on client PC at logon

Posted on 2011-03-10
8
Medium Priority
?
1,671 Views
Last Modified: 2012-05-11
I would like to add a line to my existing script to force a group policy update for my laptop users upon logon.  I have the PSEXEC tool in the root of my C: drive for all my laptop users.  What would the correct command and syntax be for this?

I believe this works in a batch file but need it to run in a script
c:\psexec.exe \\%comp_name% gpupdate.exe /force

Help is appreciated, thanks!
0
Comment
Question by:jmchristy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 8

Accepted Solution

by:
jawa29 earned 1000 total points
ID: 35096988
Hi jmchristy

You could just call it like this.

Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "gpupdate /force",,True

Jawa29

0
 

Author Comment

by:jmchristy
ID: 35097142
I'm getting a Line 25, Char 1, error Variable is undefined: oShell
code: 800A01F4

When I try to put that in the script
0
 
LVL 8

Expert Comment

by:jawa29
ID: 35097306
You need to add it to the Dim if your script is set as option explicit.

Jawa29
0
Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

 

Author Comment

by:jmchristy
ID: 35097356
Super, got it.
Anyway to hide that gpupdate screen as well?
0
 
LVL 8

Expert Comment

by:jawa29
ID: 35098162
Add Const vbHide = 2 to the very top of your script then append the code as below.

oShell.Run "gpupdate /force", vbHide, True

Jawa29

0
 

Author Comment

by:jmchristy
ID: 35098659
Getting an error on Line 2 Char 1, expected statement

I put Const vbHide = 2 at the very top
0
 
LVL 8

Expert Comment

by:jawa29
ID: 35099205
Sorry, option explicit should be the first line then all your const sit under that.

Jawa29
0
 

Author Comment

by:jmchristy
ID: 35099266
Got it, works!  Thank you.
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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