Wednesday, October 29, 2014

How would I query, then toggle Windows updates off and on via a batch file?

Please take it easy on me if I speak out of place is this is my first post. :-) but I've been looking for a way to query the Windows Update service through a batch file and based on its current state, either turn it off or on. Ultimately, I want to be able to query if the service is started, then stop it. On top of that, I want to be able to query if its set to auto start with Windows and disable. Then i was the same batch file to query and possibly go the other. like if on, turn off. If off, turn on. or possibly query, then give the option to leave off/on or change the state and start of the service.



I found out how to do these things separately (mostly through this site) by using the following commands:





  • sc start wuauserv

  • sc stop wuauserv

  • Query wuauserv

  • sc config wuauserv start= auto

  • sc config wuauserv start= disabled



So with these i can create two different files to both stop the service and disable it on startup and a separate file to start the service and set the startup to auto, but I would like to do all this with one file if possible.




So this was so long but wanted to make sure I got my goal across and show that i did do some preemptive research.



Update:
Had to zoom in a little bit on your example:
enter image description here
This is what mine looks like when i right clicked on the .bat file i created and run it as admin:
enter image description here



I noticed that you appear to be using Windows 8.1 and im on Windows 7. Does that make a difference?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...