Clickable service start/stop cmd or bat file. Possible?

Page 1 of 2 12 LastLast

  1. Posts : 94
    Windows 7 Professional 32-bit///Vista Home Premium 32-bit
       #1

    Clickable service start/stop cmd or bat file. Possible?


    Not sure if I labelled this post right, or if I am even posting this in the right category/forum.

    If admins could direct this if need be, that would be cool.

    What I would like to do is have some kind of .cmd or .bat file that will turn on or restart my PS3 Media Server service, just by clicking it.
    Maybe one that stops the service as well, or even one that can restart it.

    I currently have a shortcut to services on the desktop, but it can be annoying when I have to restart the server numerous times because of various issues, and I have to scroll thru all the services, find PS3 Media Serve service, right click, restart.
    When I start PS3 Media server as a task (so you can see the GUI), with the .exe file, you simply save your settings, hit Quit, then click the .exe on the desktop and VOILA, settings saved, and server restarted.

    With the service installed and enabled, you can't quickly access the GUI and see your buffer or other values as running two instances of javaw.exe makes things go all screwy.

    So, with the service, in order to change settings, I have to disable the service, then click the PMS.exe on my desktop so that PMS opens as a task. I then change any settings, save them, quit the GUI, then open services, and restart the service.
    And the "restart http server" option has been broke for some time now. There are so many issues right now with PMS that many people don't want the extra headache of solving service issues, and most use a shortcut copy of their .exe in their shell:startup folder.

    I figure if I can have some kind of quick way to make the service stop, click the .exe, do my thing with settings in the GUI (task startup), then close and click something to make the service start again.

    I know this sounds like I am being lazy, but if someone could point me in the right direction on how to do this, my serving world would be greatly improved.

    First off is this possible? Second, where and what would I even look up. Creating working .cmd or .bat files is WAAAY out of my league. I have learned how to edit some in PMS for Java heap settings to maximize my buffer capacity, but starting/creating such an option is beyond me.

    If anyone needs anymore info, glad to give it. I asked a while back in the forums over there, but my thread got overlooked, and I find that stuff like this is better left to....well.....the pros.

    Any ideas, and thanks in advance. Looking forward to learning something new.
    Last edited by Holy Moses; 08 Nov 2010 at 08:27. Reason: some errors
      My Computer


  2. Posts : 31,250
    Windows 11 Pro x64 [Latest Release and Release Preview]
       #2

    You can use the netsh tool (netsh.exe) to automate the control of services - add a suitably edited batch file or even a scheduled task, to run the following ...


    As admin.

    start a service:
    Net start service_name

    stop a service:
    Net stop service_name


    or as user or admin

    Pausing a service:
    Net pause service_name

    Resuming a service:
    Net continue service_name

    To crate the Bat file

    create a new text document - and add the command above on a separate line
    save the .txt file

    Rename the text file to have a bat extension
    you will get a warning that changing an extension is not a good idea, but in this instance it is OK
      My Computers


  3. Posts : 6,305
    Windows 7 Ultimate x64
       #3

    Also, you will need to have 'Hide extensions of all known file types' unchecked too in order to change the extension.

    Clickable service start/stop cmd or bat file.  Possible?-capture.png
       Tip
    Explorer -> 'Organize' -> 'Folder and Search options' -> View



    OS
      My Computer


  4. Posts : 94
    Windows 7 Professional 32-bit///Vista Home Premium 32-bit
    Thread Starter
       #4

    Cool, I will give this a try and let you know how I make out. Hope it works, thank you very much Nigel.

    EDIT: and thank you to Orbital Shark, good point, though I already have file extensions visible. But this will hopefully help others who might want to do this, so thank you.
      My Computer


  5. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #5

    To add to that what Nigel told:

    Command net stop service_name stops the named service, net start service_name starts itas Nigel mentioned. When you have saved it as a batch-file with extension .bat, you can not run it by double clicking because to start or stop services, you need built-in administrator rights. The option Run as administartor is grayed out in batch file properties, it can not be chosen. You can run the batch to start or stop a service only by right clicking it and choosing Run as administrator from context menu.

    Clickable service start/stop cmd or bat file.  Possible?-batchproperties.png

    A simple workaround is to create a shortcut to that batch file. Also in Shortcut properties is the option Run as administrator grayed out, if you look the Compability tab. But shortcut properties also has a Shortcut tab, where you can choose Advanced and surprise surprise, another place to choose run as administrator.

    Clickable service start/stop cmd or bat file.  Possible?-shortcutproperties.png

    Now you can double click the shortcut to run your batch files as administrator. UAC still prompts asking are you sure, but at least you don't have to run your batch from context menus, simple double click and telling UAC "yes, I'm sure" is enough.

    Clickable service start/stop cmd or bat file.  Possible?-capture.png

    If using notepad, remember to choose Save as type All files to avoid otherwise automatically added .txt file extension, and add the .bat extension to the file name.

    Clickable service start/stop cmd or bat file.  Possible?-netstopbat.png

    Kari
    Last edited by Kari; 08 Nov 2010 at 20:28. Reason: Noticed some typos... As always ;)
      My Computer


  6. Posts : 94
    Windows 7 Professional 32-bit///Vista Home Premium 32-bit
    Thread Starter
       #6

    Ok. I tried to stop the service via the command line in netsh>

    I entered :

    net stop PS3 Media Server

    Reply: The following command was not found: net stop PS3 Media Server

    I then tried:

    net stop PS3_Media_server (because of the way you wrote your description)

    Reply: same as before.

    Am I doing something inherently wrong here? I have started and stopped a service or two with this method ( I am pretty sure) but it was a while back.

    I could try doing the .txt file do .bat thing and enter the values, but I figured if I can't get it to do it at the command line, I must not have it correct, and making a .bat file would be a waste of time. Please tell me it is something silly and easy to remedy.

    EDIT: @ Kari......Thanks for that tip to enable double click. Now, I run the hidden admin account, or super admin, whatever the hell it is called. I have UAC disabled and never have admin issues and don't see those annoying pop up, "are you sure" windows......only with permissions if I unplug a HDD or move an already shared folder or something then my admin rights can be jeopardized.

    I know UAC is there for a reason, but I just have to have it disabled. It just drives me nuts.

    Definitely a cool workaround, if I can figure out the proper syntax, or line command....whatever it would be referred to as.
    Last edited by Holy Moses; 08 Nov 2010 at 07:27. Reason: New info from Kari.
      My Computer


  7. Posts : 6,305
    Windows 7 Ultimate x64
       #7

    You run net stop and net start from command prompt (as administrator).

    The syntax you need is net stop "ps3 media server". By adding the " you're telling it to look for the string value name of the service.

    Clickable service start/stop cmd or bat file.  Possible?-capture.png
      My Computer


  8. Posts : 5,056
    Windows 7 x64 pro/ Windows 7 x86 Pro/ XP SP3 x86
       #8

    Try

    net stop "PS3 Media Server"
    net start "PS3 Media Server"
      My Computer


  9. Posts : 94
    Windows 7 Professional 32-bit///Vista Home Premium 32-bit
    Thread Starter
       #9

    Orbital Shark said:
    You run net stop and net start from command prompt (as administrator).

    The syntax you need is net stop "ps3 media server". By adding the " you're telling it to look for the string value name of the service.

    Clickable service start/stop cmd or bat file.  Possible?-capture.png
    Bingo! I don't remember having to add the quotes, but that did it. Immediately, my server disconneted, then reconnected with the start command.

    Also was doing it from the netsh> line. Probably not right either.

    but now I feel confident in it working. Thank you to ALL!

    Very cool info, and you guys amaze me how fast you recall this info when needed. AWESOME.

    Cheers, you have just added the cherry on top for my server now. I don't think I can tweak it any better than it is now. Well maybe......lol!!!
      My Computer


  10. Posts : 6,305
    Windows 7 Ultimate x64
       #10

    Thanks for your kind words and we're always glad to help :)

    Please enjoy the rest of the forums :)
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:08.
Find Us