We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to write a script and run it on Group Policy?

Medium Priority
620 Views
Last Modified: 2012-05-11
Hello All,

I'm running WSUS and for some reasons I wanna run the following:

1- Net Stop WUAUServ
2- Delete C:\Windows\SoftwareDistribution
3- Net Start WUAUServ

These 3 commands will stop updating service, delete updates that might be corrupted then restart the service, how to write such a script and how to implement it on Group Policy?


Thanks
Comment
Watch Question

Paul MacDonaldDirector, Information Systems
CERTIFIED EXPERT

Commented:
1. Write your script and save it in your domain's SYSVOL\<domainname>\Scripts folder.
In ADUC create or edit a GPO.
2. Go to the Computer or User Configuration, depending on how you want your script to run.
3. Under Window Settings > Scripts you'll see StartUp and Shutdown (or Logon and Logoff).  Double-click the event you want and "Add..." the script
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
EE:
Do the numbers really have to be that big?  Screen HOG, sorry guys, first time I've tried that

Author

Commented:
@tmassa99

Will that work with earlier OS like XP? cuz I got this note:

"PowerShell scripts requires at least Windows 7 or Windows Server 2008."

However I found this article: http://social.technet.microsoft.com/Forums/en/winserverGP/thread/a8921d68-5115-448a-b489-16b941a971f6

So is the above script written to work on legacy OS too?

Thanks
CERTIFIED EXPERT

Commented:
This is a VBScript, so it will work on either

Author

Commented:
I modified the code to be a batch as follow:

net stop wuauserv
rd /s /q %windir%\SoftwareDistribution
net start wuauserv
%windir%\system32\wuauclt.exe /detectnow

Open in new window


I configured it to be on startup however I wanna do it only once on a specific time, is there a way to do it? Like I wanna run the script on 6 PM everyday.

Thanks
Paul MacDonaldDirector, Information Systems
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.