Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

PSEXEC script command to force gpupdate on client PC at logon

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
jmchristy
Asked:
jmchristy
  • 4
  • 4
1 Solution
 
jawa29Commented:
Hi jmchristy

You could just call it like this.

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

Jawa29

0
 
jmchristyAuthor Commented:
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
 
jawa29Commented:
You need to add it to the Dim if your script is set as option explicit.

Jawa29
0
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
jmchristyAuthor Commented:
Super, got it.
Anyway to hide that gpupdate screen as well?
0
 
jawa29Commented:
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
 
jmchristyAuthor Commented:
Getting an error on Line 2 Char 1, expected statement

I put Const vbHide = 2 at the very top
0
 
jawa29Commented:
Sorry, option explicit should be the first line then all your const sit under that.

Jawa29
0
 
jmchristyAuthor Commented:
Got it, works!  Thank you.
0

Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

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