Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ExecApp to Start/Stop Windows Service?
#1
I have a finicky service that isnt always well behaved and I have to stop/start it. 

I'm trying to fix it with a button that calls ExecApp() but cant seem to get it working. I've tried a few things:
 - Calling "net" as the command with "start <service>" as the parameters
 - Calling "cmd" as the command with "/c net start <service>" as the parameters
 - Creating a batch file and calling that

None seem to work. 

Is there a proper way to do this?
Reply
#2
The application that calls it would have to have admin privileges to do that, so it may be failing for that reason. Where you are invoking it from?
Dean Roddey
Software Geek Extraordinaire
Reply
#3
I tried two places to call it

1 - from the Admin interface, using the "Test" feature of the Global Action. It tests and exits without an error, but nothing happens to the service

2 - From the Amazon Echo. I can get the action to trigger, but nothing to the service.

Not sure if there is logging I can turn on to get more details, but I'm not sure why its failing. And I do agree about admin privileges - The app shell should have sufficient access, correct?
Reply
#4
The app shell would only have sufficient privileges if you run it under a standard account probably. The default system service account might not have sufficient rights to affect other services.
Dean Roddey
Software Geek Extraordinaire
Reply
#5
Log the CQC service on with an account that has admin rights and then run it from an action.

you can stop and start in one line as well

net stop <service> && net start <service>

Use this a lot with CQC and other systems for manually restarting a service quickly.
Mykel Koblenz
Illawarra Smart Home
Reply
#6
So I must be doing something basic wrong...


I've changed the CQC Services to run as a local admin account. Here's my global action:

Code:
System::ExecApp
    P1=cmd.exe
    P2=/c net start "emby server"
    P3=c:\windows\
    P4=Show



If I run it within the admin tool or call it through the echo, it runs with no error, but the service doesnt start

Any idea? Znelbok - do you have a sample you can cut + paste here?
Reply
#7
Does the application to run have to be quoted? So maybe:

"net start 'emby server'"

or something like that? So doubles for the overall thing and singles to handle the inner thing? Oh, wait, you said it worked ok when run from the foreground, so nevermind.

I'd change the last parameter to something that doesn't try to show the window, since it can't be shown when run from a service. Probably it just ignores that but it never hurts to try everything.
Dean Roddey
Software Geek Extraordinaire
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Please report Windows 1803 compatibility RichardU 16 404 Yesterday, 11:39 AM
Last Post: Dean Roddey
  Backup without Stopping Service RichardU 5 359 02-14-2018, 02:28 PM
Last Post: znelbok
  Windows 10 barely moving after upgrade. Deane Johnson 7 601 12-10-2017, 04:46 PM
Last Post: Dean Roddey
  Windows Server 2016 Essentials and CQC kblagron 2 446 11-30-2017, 11:00 PM
Last Post: kblagron
  ExecApp and .bat simon 15 2,342 11-16-2017, 06:27 PM
Last Post: Dean Roddey
  A word of warning regarding the Windows 10 Fall Creators Update Mark Stega 40 4,673 11-13-2017, 10:56 AM
Last Post: Dean Roddey
  Issues after fall Windows updates Ron Haley 3 622 10-24-2017, 06:35 PM
Last Post: Ron Haley
  rotate on windows 10 indygreg 3 982 08-09-2017, 07:26 AM
Last Post: Dean Roddey
Exclamation Windows as a service? Now, there’s an argument for Linux batwater 5 1,452 04-19-2017, 10:42 AM
Last Post: Dean Roddey
  IV start in full screen George M 2 817 01-21-2017, 01:39 PM
Last Post: George M

Forum Jump:


Users browsing this thread: 1 Guest(s)