6

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.

2 Answers 2

7

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

3
  • Thanks. I found one thing when the service is automatic + not running, then disable shortcut is not working. Its working when automatic + running
    – proseosoc
    Commented Jan 2, 2017 at 16:16
  • @BlackFire Ah. That is because the stop fails. Change the && to & and it will run the second command even if the first command fails. I've updated the answer.
    – DavidPostill
    Commented Jan 2, 2017 at 16:21
  • @BlackFire No problem. My fault for not thinking about the corner cases ...
    – DavidPostill
    Commented Jan 2, 2017 at 18:28
4

On Windows:
- Right click the desktop.
- Select "New->Shortcut" from the menu to create a shortcut.
- Instead of the location of the item, in the "Type the location of the item" dialog box enter your Command Prompt arguments.

Once the shortcut has been created:
- Right click the shortcut to go to "Properties".
- Select "Advanced" option in the "Shortcut" tab and tick "Run as administrator".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .