Search code examples
windowswindows-servicesshortcut-file

Desktop shortcut to restart a windows service


Is it possible to create a windows desktop shortcut that will restart a windows service?

I'd like a button to restart my apache service after I have made changes to the config file.


Solution

  • You can do this in a batch file, then make a shortcut to it.

    Create a text file with the following content, but save it with the file extension .bat

    net stop "Service Name"
    net start "Service Name"
    

    Once the file exists, you can create a shortcut to it, and even assign a keyboard shortcut too if deemed necessary.