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

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

gpupdate bat file

hi guys
I'm looking batch file with will update polocies in domain envoriment and restart pc at prompt (after updateng polocies)
my batch file is now

"Echo Yes|gpupdate.exe /force"  BUT user still have click Y and enter and i want this be inclouded in bat

any ideas

all contributions much appreciated
0
drogi
Asked:
drogi
  • 3
  • 3
  • 2
  • +2
1 Solution
 
g000seCommented:
Hi,

Try this line-

echo Yes|gpupdate /force
0
 
TazDevil1674Commented:
Not all programs will accecpt text via a pipe.

Not something I have done recently but you might want to try

  gpupdate /force /yes

I know gpupdate /force /no stops the reboot...

HTH
0
 
Elmar KoschkaIT System EngineerCommented:
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
g000seCommented:
Sry had one more item to add my post previously.  Try placing quotes around the word "yes"
0
 
Elmar KoschkaIT System EngineerCommented:
gpupdate /force /boot works for me
0
 
drogiAuthor Commented:
echo yes|gpupdate /force /yes
I've tried this and no joy cmd just flashes and do nothing
0
 
Lionel MMSmall Business IT ConsultantCommented:
What OS are you trying this on, version of Windows?
0
 
drogiAuthor Commented:
windows 7
0
 
Lionel MMSmall Business IT ConsultantCommented:
Option 1
Create this in a batch file
Rem This will create a scheduled task either local or remote and will run gpupdate within 1 minute, unless you specify a start time (ST)
SCHTASKS /Create /S ComputerName /U domain\username /P password /SC MINUTE /MO 1 /TN TaskName  /TR "gpupdate /force" /ST StartTime--defaults to now if no time specified
Rem This will then reboot your PC within 3 minutes
Shutdown -f -r -t  180 -m ComputerName

Alternatively you can create a batch file for the schedule to start instead of starting gpupdate directly. If you go this root you must either have the batch file on each system or have it ina central location all users have access to--I will assume a central location located at g:\Utils\GP-Update.Bat. In this option this batch file will be scheduled and not gpupdate and shutdown/restart will not start until gpupdate is done

Option 2
Create this in a batch file
Rem GP-Update.Bat
:gpupdate /force
Shutdown -f -r -t  120

Now create a scheduled task to run this batch file
SCHTASKS /Create /S ComputerName /U domain\username /P password /SC MINUTE /MO 1 /TN TaskName  /TR G:\Utils\GP-Update.bat /ST StartTime--defaults to now if no time specified

Depending on permissions and who you specify as /U user this by itself may work but if not you may have to use the run as user command /RU and /RP (note if passwords are not specified they will be asked for). Hope this helps.
0
 
Lionel MMSmall Business IT ConsultantCommented:
Correction--was :gpupdate (:) should be gpupdate without the :  -- sorry about that
Option 2
Create this in a batch file
Rem GP-Update.Bat
gpupdate /force
Shutdown -f -r -t  120
0
 
drogiAuthor Commented:
thanks
0

Featured Post

New feature and membership benefit!

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

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now