Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Basically, the wacom drivers seem to need to be restarted more often than I'd like. Thankfully, they put a handy button in the settings to do just that, but I would really love to be able to do this with AHK and not have to click through the settings. Does anyone have any advice on where to find where that service is running, and then restart it with a hotkey?
I have found the "WacomProfessionalService" in services.msc by following this guide. Any advice?
Thank you!!!!!!
I have found the "WacomProfessionalService" in services.msc by following this guide. Any advice?
Thank you!!!!!!
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Code: Select all
F3::Run, sc.exe STOP "WacomProfessionalService",, Hide
START works, too, in place of STOP.
Code: Select all
svc = WacomProfessionalService
F3::
SoundBeep, 1500
RunWait, sc.exe STOP "%svc%",, Hide
Sleep, 500
RunWait, sc.exe START "%svc%",, Hide
SoundBeep, 1000
Return
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Thanks so much for this!! Unfortunately, I can't quite get it to work. I've tried using the display name, service name, and service location listed in the service properties. Any ideas?
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Use the service name. Try admin mode.
Code: Select all
If !A_IsAdmin && !RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)") {
Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
ExitApp
}
svc = WacomProfessionalService
F3::
SoundBeep, 1500
RunWait, sc.exe STOP "%svc%",, Hide
Sleep, 3000
RunWait, sc.exe START "%svc%",, Hide
SoundBeep, 1000
Return
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Wow thank you again! Unfortunately, not quite working yet. I did test the code in an admin cmd prompt and "sc stop WTabletServicePro" works flawlessly, but you're right, it definitely needs admin access. I would assume that means that your topline for sending as admin isn't working as expected?
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
It works here for other services, but I do not have the Wacom service. You can test it with a Windows service. The admin code here applies to an uncompiled AHK script.
How are you verifying that the script works or does not work?
How are you verifying that the script works or does not work?
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Ok I just tested it with a windows service, and it still doesn't seem to be working. I recorded a video of the process if you want to check that out here (ignore the fact that my mouse is misaligned, sorry). But I am testing verifying the script by refreshing the services.msc services app. Additionally, when I stop the wacom service via cmd prompt, my tablet stops working (easiest way to tell whether it's active or not). Thoughts?
Thanks so much again for all your help.
Thanks so much again for all your help.
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
You are using a different script. Try the one that I posted first. Run is not RunWait. Documentation explains the difference. If your script does not work, then post the script here.
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Sorry for the confusion there! Still, with RunWait, the services dont get stopped with that script. Here's another recording.
I really appreciate you bearing with me on all this!
I really appreciate you bearing with me on all this!
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
If your script does not work, then post the script here.
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Sure thing. Here ya go!
Here it is trying to stop the font cache:
The wacom service name is WTabletServicePro.
Here it is trying to stop the font cache:
Code: Select all
If !A_IsAdmin && !RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)") {
Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
ExitApp
}
svc = FontCache
F3::
SoundBeep, 1500
RunWait, sc.exe STOP "%svc%",, Hide
;Sleep, 3000
;RunWait, sc.exe START "%svc%",, Hide
;SoundBeep, 1000
Return
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
I'm not sure that you can stop the font service, but the following one works.
If you cannot stop your Wacom service with this approach, I do not have an answer. Others here may know more.
Code: Select all
If !A_IsAdmin && !RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)") {
Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
ExitApp
}
svc = stisvc
F3::
SoundBeep, 1500
RunWait, sc.exe STOP "%svc%",, Hide
;Sleep, 3000
;RunWait, sc.exe START "%svc%",, Hide
;SoundBeep, 1000
Return
Re: Struggling to figure out how I might restart a windows service with a hotkey. Can you help?
Ok well that seems to work well for stopping. Unfortunately it does not work for starting again. And ofc doesn't work for the wacom service. Anyways, thanks again for all your help!! Hopefully others may have an answer.