Starting and Stopping Services

S

Stan Brown

My backup program requires two services to be running when I do a
backup. Naturally, I want those services not to be running at other
times. So I created the following batch file:

1. sc start afcdpsrv
2. sc start AcrSch2Svc
3. start /wait "C:\Program Files (x86)\Acronis\TrueImageHome
\TrueImageLauncher.exe"
4. sc stop afcdpsrv
5. sc stop AcrSch2Svc

(Line numbers are for reference and don't appear in the file.)

I've got two problems, which I'm hoping someone can help with. I
opened a command prompt with elevated privilege (yes, I got the
black-screen warning, so I know it worked), and ran the batch file.

A. Lines 1 and 2 show in the display that start is *pending*. And
when I check with SERVICES.MSC they are indeed stopped. (The service
names came from the Properties dialog in SERVICES.MSC.)

B. Line 3 opened a new command prompt but did not start the program.
It's hard to believe I could screw up a START command, but obviously
I have. I can't see my mistake, though. (The stuff in quotes was
copy/pasted from the Target box in the shortcut, so I do know that
it's correct.)

Thanks to any who can help!
 
S

Seth

Stan Brown said:
My backup program requires two services to be running when I do a
backup. Naturally, I want those services not to be running at other
times. So I created the following batch file:

1. sc start afcdpsrv
2. sc start AcrSch2Svc
3. start /wait "C:\Program Files (x86)\Acronis\TrueImageHome
\TrueImageLauncher.exe"
4. sc stop afcdpsrv
5. sc stop AcrSch2Svc

(Line numbers are for reference and don't appear in the file.)

I've got two problems, which I'm hoping someone can help with. I
opened a command prompt with elevated privilege (yes, I got the
black-screen warning, so I know it worked), and ran the batch file.

A. Lines 1 and 2 show in the display that start is *pending*. And
when I check with SERVICES.MSC they are indeed stopped. (The service
names came from the Properties dialog in SERVICES.MSC.)

B. Line 3 opened a new command prompt but did not start the program.
It's hard to believe I could screw up a START command, but obviously
I have. I can't see my mistake, though. (The stuff in quotes was
copy/pasted from the Target box in the shortcut, so I do know that
it's correct.)
Instead of "sc start service" (or stop) try "net start service" (or
stop)(replace service with the service name).
Do you need to launch the backup program with an instance of "start"? Can't
you just launch it directly? Start is specifically for when you need a new
window.

And lastly, what's the problem with leaving the services running at all
times as they were designed? Are they that big of resource hogs that it
makes a difference?
 
S

Steel

My backup program requires two services to be running when I do a
backup. Naturally, I want those services not to be running at other
times. So I created the following batch file:

1. sc start afcdpsrv
2. sc start AcrSch2Svc
3. start /wait "C:\Program Files (x86)\Acronis\TrueImageHome
\TrueImageLauncher.exe"
4. sc stop afcdpsrv
5. sc stop AcrSch2Svc

(Line numbers are for reference and don't appear in the file.)

I've got two problems, which I'm hoping someone can help with. I
opened a command prompt with elevated privilege (yes, I got the
black-screen warning, so I know it worked), and ran the batch file.

A. Lines 1 and 2 show in the display that start is *pending*. And
when I check with SERVICES.MSC they are indeed stopped. (The service
names came from the Properties dialog in SERVICES.MSC.)

B. Line 3 opened a new command prompt but did not start the program.
It's hard to believe I could screw up a START command, but obviously
I have. I can't see my mistake, though. (The stuff in quotes was
copy/pasted from the Target box in the shortcut, so I do know that
it's correct.)

Thanks to any who can help!
Maybe that third line needs to run with Run as Admin, and you are
assuming it has the rights. But it doesn't have the Run as Admin rights,
which could be set on the propertie of the exe or a short-cut propertie
pointing to the exe.
 
S

SC Tom

Stan Brown said:
My backup program requires two services to be running when I do a
backup. Naturally, I want those services not to be running at other
times. So I created the following batch file:

1. sc start afcdpsrv
2. sc start AcrSch2Svc
3. start /wait "C:\Program Files (x86)\Acronis\TrueImageHome
\TrueImageLauncher.exe"
4. sc stop afcdpsrv
5. sc stop AcrSch2Svc

(Line numbers are for reference and don't appear in the file.)

I've got two problems, which I'm hoping someone can help with. I
opened a command prompt with elevated privilege (yes, I got the
black-screen warning, so I know it worked), and ran the batch file.

A. Lines 1 and 2 show in the display that start is *pending*. And
when I check with SERVICES.MSC they are indeed stopped. (The service
names came from the Properties dialog in SERVICES.MSC.)

B. Line 3 opened a new command prompt but did not start the program.
It's hard to believe I could screw up a START command, but obviously
I have. I can't see my mistake, though. (The stuff in quotes was
copy/pasted from the Target box in the shortcut, so I do know that
it's correct.)

Thanks to any who can help!
Along with Seth's suggestion of using the "Net" command instead of "sc", do
you have the first two services set to manual? If so, they should not be
running all the time, but will start when needed by the ATI program. Then
your bat file would be

"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe"
net stop afcdpsrv
net stop AcrSch2Svc

That should be all you need, if you really need those services stopped. You
may have to set the privileges of the bat to run as admin.
 
S

Stan Brown

Along with Seth's suggestion of using the "Net" command instead of "sc", do
you have the first two services set to manual? If so, they should not be
running all the time, but will start when needed by the ATI program. Then
your bat file would be

"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe"
net stop afcdpsrv
net stop AcrSch2Svc

That should be all you need, if you really need those services stopped. You
may have to set the privileges of the bat to run as admin.
Thanks for your comments. Here are answers, and some follow-on
questions that they raise.

1. The services are set as manual, but they do *not* start when True
Image starts. I have to start them myself.

2. Changing "sc" to "net" does indeed make the services start and
stop as desired. That leads to a new question: why doesn't sc work?
From the text of "sc /?" it certainly seems that it should.

3. Without the START command, I can't have the /WAIT parameter. If I
simply put the command on the line, without START /WAIT, doesn't that
mean True Image gets launched and immediately the batch file stops
the two services?

4. Why does the START command open a second command prompt instead of
launching the program?

5. Do I "really need those services stopped"? I suppose it's
debatable, but why *should* they be running all the time? It's pretty
daft of Acronis to have an Acronis-specific scheduler service running
when I don't have scheduled backups. (I can't schedule backups,
because they are to an external drive that is connected only during
the creation of a backup.) Lots of applications seem to think that
their particular service should run all the time, and while an
individual one might not be too bad, cumulatively they slow the boot
process and drag down performance.

6. I don't have this whole UAC thing down 100%, but when I open a
command prompt with elevated privilege, and get the black-screen
request for permission to make changes to the computer, doesn't
everything that runs in the batch file have elevated privilege?
 
Z

Zaidy036

Stan Brown said:
Thanks for your comments. Here are answers, and some follow-on
questions that they raise.

1. The services are set as manual, but they do *not* start when True
Image starts. I have to start them myself.

2. Changing "sc" to "net" does indeed make the services start and
stop as desired. That leads to a new question: why doesn't sc work?
From the text of "sc /?" it certainly seems that it should.

3. Without the START command, I can't have the /WAIT parameter. If I
simply put the command on the line, without START /WAIT, doesn't that
mean True Image gets launched and immediately the batch file stops
the two services?

4. Why does the START command open a second command prompt instead of
launching the program?

5. Do I "really need those services stopped"? I suppose it's
debatable, but why *should* they be running all the time? It's pretty
daft of Acronis to have an Acronis-specific scheduler service running
when I don't have scheduled backups. (I can't schedule backups,
because they are to an external drive that is connected only during
the creation of a backup.) Lots of applications seem to think that
their particular service should run all the time, and while an
individual one might not be too bad, cumulatively they slow the boot
process and drag down performance.

6. I don't have this whole UAC thing down 100%, but when I open a
command prompt with elevated privilege, and get the black-screen
request for permission to make changes to the computer, doesn't
everything that runs in the batch file have elevated privilege?
#3 is missing the "window title"
 
S

Stan Brown

#3 is missing the "window title"
Interesting! Thanks for your help.

"START /?" has the window title in brackets, indicating that it's
optional. However, before I posted that I tried it, and sure enough!
with the window title specified, the command prompt now launches the
program instead of launching a second command prompt. So this is
definitely progress.

But now I have another problem. Could it be another documentation
error? /WAIT is ignored: i.e., Acronis launches and the batch file
immediately begins stopping the services. Indeed, "START /?" says
that if command extensions are enabled then "When executing an
application that is a 32-bit GUI application, CMD.EXE does not wait
for the application to terminate before returning to the command
prompt."

When I look at "CMD /?" it says that SETLOCAL DISABLEEXTENSIONS will
override other settings and disable command extensions. But that
doesn't seem to work for me; the /WAIT is still ignored. Am I doing
something else wrong, or is this another error in the documentation
(and how would I work around it)?

My batch file now reads (again, with line numbers added for clarity):
1. setlocal disableextensions
2. net start afcdpsrv
3. net start AcrSch2Svc
4. start "Acronis" /wait "C:\Program Files (x86)\Acronis
\TrueImageHome\TrueImageLauncher.exe"
5. net stop afcdpsrv
6. net stop AcrSch2Svc
 
Z

Zaidy036

Stan Brown said:
Interesting! Thanks for your help.

"START /?" has the window title in brackets, indicating that it's
optional. However, before I posted that I tried it, and sure enough!
with the window title specified, the command prompt now launches the
program instead of launching a second command prompt. So this is
definitely progress.

But now I have another problem. Could it be another documentation
error? /WAIT is ignored: i.e., Acronis launches and the batch file
immediately begins stopping the services. Indeed, "START /?" says
that if command extensions are enabled then "When executing an
application that is a 32-bit GUI application, CMD.EXE does not wait
for the application to terminate before returning to the command
prompt."

When I look at "CMD /?" it says that SETLOCAL DISABLEEXTENSIONS will
override other settings and disable command extensions. But that
doesn't seem to work for me; the /WAIT is still ignored. Am I doing
something else wrong, or is this another error in the documentation
(and how would I work around it)?

My batch file now reads (again, with line numbers added for clarity):
1. setlocal disableextensions
2. net start afcdpsrv
3. net start AcrSch2Svc
4. start "Acronis" /wait "C:\Program Files (x86)\Acronis
\TrueImageHome\TrueImageLauncher.exe"
5. net stop afcdpsrv
6. net stop AcrSch2Svc
With ATI use the option for commands to run before and after image is made
then write batch files for what you want to do
 
J

Joe Morris

[edited]
1. sc start afcdpsrv
2. sc start AcrSch2Svc
3. start /wait "C:\Program Files (x86)\Acronis\TrueImageHome
\TrueImageLauncher.exe"
4. sc stop afcdpsrv
5. sc stop AcrSch2Svc

(Line numbers are for reference and don't appear in the file.)
[...]
B. Line 3 opened a new command prompt but did not start the program.
It's hard to believe I could screw up a START command, but obviously
I have. I can't see my mistake, though. (The stuff in quotes was
copy/pasted from the Target box in the shortcut, so I do know that
it's correct.)
Caveat: I have no experience with TrueImage so the following may or may not
be helpful and might even be misleading...

1: You may have a race condition. If when you installed ATI the services
were created with "automatic" (or "deferred") start and you've now changed
them to manual start, you may be having troubles if the ATI design assumes
that the launcher can't be invoked before the services have had enough time
to complete their initialization. To test this, try manually starting the
two services, sit on your hands for a minute or two, *then* start the ATI
application.

2: The name of the application given in the START command suggests that your
problem with the /WAIT not being honored may be in the design of ATI. The
word "LAUNCHER" leads me to suspect that the application being invoked from
the START command is NOT the actual backup program, but one that instead
interacts with one (or both) of the services to start the backup process.
If this is the case, the Launcher (tries) to invoke a function in one of the
services (possibly failing because they are still running their
initialization logic) and terminates...thus satisfying the /WAIT switch. A
possible test for this would be to run ATI on a system where its
configuration hasn't been changed, and seeing if, while it's running, you
have a process named "TrueImageLauncher.exe".

A possible workaround would be to figure out what process name represents
ATI performing a backup, then write a short script that waits for the
process of that name to disappear, after which the two services can be
stopped.

Joe Morris
 
C

Char Jackson

2: The name of the application given in the START command suggests that your
problem with the /WAIT not being honored may be in the design of ATI. The
word "LAUNCHER" leads me to suspect that the application being invoked from
the START command is NOT the actual backup program, but one that instead
interacts with one (or both) of the services to start the backup process.
If this is the case, the Launcher (tries) to invoke a function in one of the
services (possibly failing because they are still running their
initialization logic) and terminates...thus satisfying the /WAIT switch. A
possible test for this would be to run ATI on a system where its
configuration hasn't been changed, and seeing if, while it's running, you
have a process named "TrueImageLauncher.exe".
You might be onto something there. The Acronis TI directory contains
the TrueImagelauncher.exe program at about 4MB, and another executable
called TrueImage.exe at about 19 MB. Double clicking the launcher
launches the program as expected, but double clicking the larger exe
also launches the program. In both cases, the launcher program never
shows up in the task list in Task Manager, probably because it quickly
hands off control to the main program.

For the script, I'm guessing it would work better to launch
TrueImage.exe rather than TrueImageLauncher.exe.
 
S

Seth

Stan Brown said:
Thanks for your comments. Here are answers, and some follow-on
questions that they raise.

1. The services are set as manual, but they do *not* start when True
Image starts. I have to start them myself.
Yeah, manual is manual. Starting when something else launches would be "On
demand".
2. Changing "sc" to "net" does indeed make the services start and
stop as desired. That leads to a new question: why doesn't sc work?
From the text of "sc /?" it certainly seems that it should.
"sc" should work, but has always been less reliable. I only use sc for
configuring services and always fall back on net for starting and stopping.
3. Without the START command, I can't have the /WAIT parameter. If I
simply put the command on the line, without START /WAIT, doesn't that
mean True Image gets launched and immediately the batch file stops
the two services?
OK, was just checking.
4. Why does the START command open a second command prompt instead of
launching the program?
Cause that is how start is designed to run unless you specifically tell it
otherwise.
5. Do I "really need those services stopped"? I suppose it's
debatable, but why *should* they be running all the time? It's pretty
daft of Acronis to have an Acronis-specific scheduler service running
when I don't have scheduled backups. (I can't schedule backups,
because they are to an external drive that is connected only during
the creation of a backup.) Lots of applications seem to think that
their particular service should run all the time, and while an
individual one might not be too bad, cumulatively they slow the boot
process and drag down performance.
Well you could always change them from Automatic to Automatic with delayed
start. Then your startup is sped up but the services will kick in a little
later and be available when needed. I would check to see what their actual
system impact when idle is before modifying from how they were designed to
be used. I don't know why the authors made them as a service or what impact
not having them run as designed are.
6. I don't have this whole UAC thing down 100%, but when I open a
command prompt with elevated privilege, and get the black-screen
request for permission to make changes to the computer, doesn't
everything that runs in the batch file have elevated privilege?
If you open a command prompt elevated and answer the UAC challenge, then
yes, anything started form that window will also be elevated. The spawned
window from the START command is a possible exception, but I wouldn't think
so.
 
Z

Zaidy036

Seth said:
Yeah, manual is manual. Starting when something else launches would be "On demand".


"sc" should work, but has always been less reliable. I only use sc for
configuring services and always fall back on net for starting and stopping.


OK, was just checking.


Cause that is how start is designed to run unless you specifically tell it otherwise.


Well you could always change them from Automatic to Automatic with
delayed start. Then your startup is sped up but the services will kick in
a little later and be available when needed. I would check to see what
their actual system impact when idle is before modifying from how they
were designed to be used. I don't know why the authors made them as a
service or what impact not having them run as designed are.


If you open a command prompt elevated and answer the UAC challenge, then
yes, anything started form that window will also be elevated. The
spawned window from the START command is a possible exception, but I wouldn't think so.
Suggest you ask questions in ATI's Forum - lots of help available
http://forum.acronis.com/forums/acr...ce-products-discussions/acronis-true-image-ho
 
S

Stan Brown

With ATI use the option for commands to run before and after image is made
then write batch files for what you want to do
It's a good suggestion except that Acronis basic functionality won't
work if the services aren't running. For example, I couldn't purge
outdated backups from the "My Backups" list until I started the
services.
 
S

Stan Brown

You might be onto something there. The Acronis TI directory contains
the TrueImagelauncher.exe program at about 4MB, and another executable
called TrueImage.exe at about 19 MB. Double clicking the launcher
launches the program as expected, but double clicking the larger exe
also launches the program. In both cases, the launcher program never
shows up in the task list in Task Manager, probably because it quickly
hands off control to the main program.

For the script, I'm guessing it would work better to launch
TrueImage.exe rather than TrueImageLauncher.exe.
Thanks, Joe and Char. I'll give that a try and report back.
 
C

Char Jackson

Well, thanks, but isn't this really a Windows 7 issue rather than an
Acronis issue. I'm working this out with Acronis now, but I'm going
to want to do a similar thing with iTunes and possibly other
programs.
I think it's more of an Acronis issue than a Windows issue. It's
Acronis that has the two helper services and the launcher program that
need to be dealt with. I'm thinking someone may have already blazed
the trail you're going down, and they may have written about it on the
Acronis forums.

What you learn there would almost certainly translate to other Win 7
automation tasks, but I think it starts with Acronis in this case.

Either way, good luck with it. I'm following the thread with interest.
 
H

hawkins

"Char Jackson" wrote in message

Well, thanks, but isn't this really a Windows 7 issue rather than an
Acronis issue. I'm working this out with Acronis now, but I'm going
to want to do a similar thing with iTunes and possibly other
programs.
I think it's more of an Acronis issue than a Windows issue. It's
Acronis that has the two helper services and the launcher program that
need to be dealt with. I'm thinking someone may have already blazed
the trail you're going down, and they may have written about it on the
Acronis forums.

What you learn there would almost certainly translate to other Win 7
automation tasks, but I think it starts with Acronis in this case.

Either way, good luck with it. I'm following the thread with interest.

--

Char Jackson



Stan, Have you considered running Acronis backups from the rescue CD?
Done that way you can happily uninstall the whole Acronis program so it will
have zero impact
on your system until you actually run a backup or a restore.

I have tried both ways on my set up and found that imaging from the CD or a
pen drive was slightly faster
than when run from the program, However I prefer to schedule my backups to
an additional internal hard drive.
The backup processes then runs automatically with no further effort from me
..

Incidentally I make regular restores of my main hard drive to prove that
everything is working correctly. This is done
after swapping out the current drive and restoring to one of a previous
generation to make this a totally risk free operation.

Richard Hawkins
 
S

Stan Brown

Thanks, Joe and Char. I'll give that a try and report back.
And now reporting back. :)

Joe and Char, you nailed it. This "launcher" apparently is an
invisible program, because when I start TrueImage directly I get the
same user interface that I see when starting TrueImageLauncher.

So my batch file, which works(*), is now:

1. setlocal disableextensions
2. net start afcdpsrv
3. net start AcrSch2Svc
4. start "Acronis" /wait "C:\Program Files (x86)\Acronis
\TrueImageHome\TrueImage.exe"
5. net stop afcdpsrv
6. net stop AcrSch2Svc
7. endlocal

This will provide a pattern for working with other bloaters, like
iTunes.

(*) "Works" -- the program launches, and display is correct, and I
confirm with Services.msc that the services start and stop in correct
synchrony. I haven't actually made a backup, but I can't imagine
that not working since it does work when I stop and start the
services myself in Services.msc.

Thanks to all for your help! There were multiple issues in my batch
file, but this was a great team effort to solve them.
 
C

Char Jackson

This will provide a pattern for working with other bloaters, like
iTunes.

(*) "Works" -- the program launches, and display is correct, and I
confirm with Services.msc that the services start and stop in correct
synchrony. I haven't actually made a backup, but I can't imagine
that not working since it does work when I stop and start the
services myself in Services.msc.

Thanks to all for your help! There were multiple issues in my batch
file, but this was a great team effort to solve them.
Thanks for the follow-up to confirm your success. Glad it's working
for you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top