Stopping a service

Get help with using AutoHotkey and its commands and hotkeys
Posts: 54
Joined: 26 Feb 2014, 01:37

Stopping a service

03 Nov 2016, 16:50

Hi. I'd like to use hotkey to stop a service, without any prompts, confirmations, etc. In W8.1. I've done a search, and have found a few theoretical solutions, but none of them are working. Everything I've tried, based on what I've found, is along these lines:

Code: Select all

^!+x::run net stop "wuauserv"  

Code: Select all

^!+x::RunWait, %comspec% /c net ... , , hide
These all run in a cmd window but are not stopping the service.

Anyone know how I can do this?

Thank you!
User avatar
Posts: 1459
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Stopping a service

03 Nov 2016, 18:47

Your second bit of code should be used. And are you running as admin?
OS: Windows 7 Ultimate | Editor: Notepad++
My Personal Function Library | Check Out My Computer Rig
Posts: 216
Joined: 27 Oct 2013, 08:32

Re: Stopping a service

05 Nov 2016, 13:11

I usually use sc instead of net and, as Masonjar13 points out, you need to run the script as Admin.

For example:

Code: Select all

; Prompt to 'Run as Admin', i.e. show UAC dialog
If Not A_IsAdmin
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+

; Stop and delete the Retail Demo service in Windows 10
RunWait,sc stop "RetailDemo",,hide
RunWait,sc config "RetailDemo" start= disabled,,hide
RunWait,sc delete "RetailDemo",,hide
Posts: 54
Joined: 26 Feb 2014, 01:37

Re: Stopping a service

08 Nov 2016, 12:20

Thanks for these replies!

Am I running as admin? I'm signed in with full admin privileges, but I'm not running AHK or this particular script "as Admin", at least not explicitly.

I will try out the above suggestions, and update results!

I want to easily shut down windows update in W8.1, which has started running frequently and will run for hours before finally doing anything. I've been manually stopping the service through Task Manager, but would rather just swat it with an AHK script. Thanks again.
Posts: 216
Joined: 27 Oct 2013, 08:32

Re: Stopping a service

08 Nov 2016, 12:40

Why not do it the other way round, i.e. disable the Windows Update and BITS services then use a script to start them when you want? I use the following batch file:

Code: Select all

REM Start the Windows Update and
REM Background Intelligent Transfer services

sc config wuauserv start= auto
sc config bits start= auto
net start wuauserv
net start bits

REM Now run Windows Update and wait

control /name Microsoft.WindowsUpdate

REM When finished, stop the services and disable them

net stop wuauserv
net stop bits
sc config wuauserv start= disabled
sc config bits start= disabled
This has the advantage of working from Windows 7 onwards...

Hope this helps...

Return to “Ask For Help”

Who is online

Users browsing this forum: aircooled, Bing [Bot], Five One, just me, njs, Odlanir, r2d2_986, scriptors and 204 guests