Saturday, November 3, 2018

How to make two shortcuts: Enable+Start service & Disable+Stop any windows service?



But at this time I need only shortcuts for windows update service. I don't keep windows update service running all time but windows store needs windows update service running. I want to enable+start windows update service before opening windows store with shortcut and disable+stop windows update service after closing windows store.



I found some good answers to restart a service here : https://stackoverflow.com/questions/1995847/desktop-shortcut-to-restart-a-windows-service




Any help will be useful for me and people with same need.



WORKED FOR ME: (windows 10)



I created two text files & paste those one line code in each (see accepted answer)



I changed those files extension to .bat



I created 2 shortcuts for both files




I edited those 2 shortcuts to run as admin, > right click on shortcut > click "properties" > go to "shortcut" tab > click "advanced" > tick "run as administrator" > OK > OK



INFO: to get any service name. Go to "services" > right click any service > properties > see service name.


Answer



How do I enable/start and stop/disable the Windows Update Service from cmd?



You can do this using sc commands.





  • Either assign the commands to a shortcut or add them to a batch file and assign the batch file to a shortcut.

  • To do the same with any other service replace wuauserv with the service name.



Enable/Start:



sc config wuauserv start= auto & sc start wuauserv


Stop/Disable:




sc stop wuauserv & sc config wuauserv start= disabled


Example output:



> sc config wuauserv start= auto & sc start wuauserv
[SC] ChangeServiceConfig SUCCESS

SERVICE_NAME: wuauserv

TYPE : 20 WIN32_SHARE_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 1204
FLAGS :


> sc stop wuauserv & sc config wuauserv start= disabled

SERVICE_NAME: wuauserv
TYPE : 20 WIN32_SHARE_PROCESS
STATE : 3 STOP_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x1
WAIT_HINT : 0x7530

[SC] ChangeServiceConfig SUCCESS





Further Reading




No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...