|
Answer» I am trying to stop a few windows services using some batch code, but I keep getting an error code.
System error 1060 has occurred. The specific service does not exist as an installed service.
Here is the code I am using...
Code: [Select]echo off cls CD C:\progra~1\Raxco\Perfec~1\ call PerfectDisk.exe NET STOP PDAgent.exe NET STOP PDEngine.exe
When PerfectDisk.exe is started, both services, PDAgent.exe and PDEngine.exe are started. But when I close PerfectDisk.exe the other two services do not close.
Any help would be appreciated.
Thanks
I'm certainly no batch expert, but are "PDAgent.exe" and " PDEngine.exe" the service names, or the filenames? As far as I am aware you must use the service name, as shown in services.msc, to use the NET STOP/START ETC commands. If this doesn't help, I'm sure someone knowing a little more will be along shortly Ahh yes. I need to remove the ".exe" as the service names are PDAgent and PDEngine.
Thus:
Code: [Select]echo off cls CD C:\progra~1\Raxco\Perfec~1\ call PerfectDisk.exe NET STOP PDAgent NET STOP PDEngine
They now close, but only AFER I manually close PerfectDisk.exe. Shouldn't the program end after the call command moves on to the next command? Or is there a better way to end PerfectDisk.exe? Is there batch language to terminate PerfectDisk.exe? I think I used it at one time.
Good to hear that is now working. As for your other questions, I'm not sure, I've not used the call command so I'm not certain what the behaviour should be but I think it should wait until the program it called is closed until it moves on, as you described. I know you could use the "taskkill /im PerfectDisk.exe" command to kill the process, but it seems like there should be a better way than that. Maybe you could try using the run command, or just the filename? I'm guessing more than anything, I'll admit that ...
QUOTE from: iONik on April 18, 2010, 11:55:12 AM I need to remove the ".exe" as the service names are PDAgent and PDEngine.
Correct. ALSO I always use quotes around the service name.
QuoteOr is there a better way to end PerfectDisk.exe?
A better way to start it, you mean. The CALL command is for starting one batch file from another and returning after completion.
Code: [Select]C:\>call /? Calls one batch program from another. [...]
For .exe (program) files you need to use the START command. In your situation where you want to wait for the program to finish, use the /WAIT switch. In addition START needs a title string (which is required, and which can be blank).
Code: [Select]echo off cls CD C:\progra~1\Raxco\Perfec~1\ start /WAIT "" "PerfectDisk.exe" NET STOP "PDAgent" NET STOP "PDEngine" Ahh Yes. You are right, Salmon TROUT. It's been a long time since I used batch code.
I did try the code you suggested, but PerfectDisk.exe did not quit after I "X'd" out of the program. But this was because the settings in the program was set to minimize to system tray. So your code works perfectly!
Thanks
|