WinAutomation - windows automation software with macro recorder
      5 replies [Last post]
      nbrannelly
      nbrannelly's picture
      User offline. Last seen 7 weeks 5 days ago. Offline
      Joined: 01/27/2010
      Posts: 9

      Hi,

      Can someone tell me how I can stop or start the service on a remote server? In addition I also need to check that the service has definatly stopped.

      Thanks

      Neil

      D.M.Altizer
      User offline. Last seen 6 hours 55 min ago. Offline
      Joined: 01/12/2010
      Posts: 193
      Re: How can I use the stop/start service option on a remote ...

      To stop a service remotely you can use the command sc in the "Run DOS Command" action.

      Example:

      -> sc \\computer stop "Service Name"
      -> sc \\computer start "Service Name"

      You can then parse the output of the command through the "Parse Text" action and depending on the results, figure out whether the command was successful or not.

      There is another way to do that, which is far more complicated and I wouldn't recommend using it (unless there is a very good reason, and I cannot think of one at the moment). This method uses VBScript and WMI to start and stop the service. If you would like to see a sample implementation, I have attached a job that I created for a customer a long time ago.

      This job will get a list of the services in the remote machine and prompt you to select which service you want to start/stop.

      However, as I foretold, I would suggest using the sc command if it suits your needs.

      AttachmentSize
      StartStopRemoteService.waj 21 KB
      __________________

      ==Dedicated Automation Solutions==

      __________________

      ==Dedicated Automation Solutions==

      nbrannelly
      nbrannelly's picture
      User offline. Last seen 7 weeks 5 days ago. Offline
      Joined: 01/27/2010
      Posts: 9
      Re: How can I use the stop/start service option on a remote ...

      Thanks D.M.

      That all works now

      Neil

      nbrannelly
      nbrannelly's picture
      User offline. Last seen 7 weeks 5 days ago. Offline
      Joined: 01/27/2010
      Posts: 9
      Re: How can I use the stop/start service option on a remote ...

      Well, it did work but I have stopped the service then I intend to run a routine of moving files around then I want to start the service again.

      When I run the script the service stops fine but when I want to start the service nothing happens. I have cut out the start part of my script and it works fine on it's own but not when it's in the main script. does anyone else have this problem? is it a bug in winautomation?

      Thanks

      Neil

      AttachmentSize
      Start Remote Service.waj 29 KB
      D.M.Altizer
      User offline. Last seen 6 hours 55 min ago. Offline
      Joined: 01/12/2010
      Posts: 193
      Re: How can I use the stop/start service option on a remote ...

       Hm... I took a look at your job and I have one question:

      Quote:
      I have cut out the start part of my script and it works fine on it's own

      What kind of changes did you make? Did you change the %WorkingDir% variable?

      Please go to action no.58 and in the working folder input field, change %WorkingDir% with "%WorkingDir%" (enclose the variable in double quotes). 

      __________________

      ==Dedicated Automation Solutions==

      __________________

      ==Dedicated Automation Solutions==

      nbrannelly
      nbrannelly's picture
      User offline. Last seen 7 weeks 5 days ago. Offline
      Joined: 01/27/2010
      Posts: 9
      Re: How can I use the stop/start service option on a remote ...

      I changed so many things to try to get this to work but it works a treat now.

      Thanks again