Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fail to start exe from a windows service unless via an intermediate batch file

1,227 views
Skip to first unread message

Andrew

unread,
Jan 10, 2012, 2:35:11 AM1/10/12
to
I have written a windows service that launches other programs. I find
that certain programs I launch that I dont have the source for, do not
launch successfully unless I launch them via an intermediate batch
file. Does anyone have any ideas on whny this might be? There is no
GUI involved, my service does not use a GUI, neither do any of the
apps that I launch. The apps being launched do write to std::cout but
shortly after they get started they redirect this to their own
logfile. Another weirdness is that I dont need the intermediate batch
file if I run my launcher not as a windows service (which I can do via
a command line switch). So there appears to be some sort of
restriction that applies to launchers that are windows services.

Also, can anyone suggest any other forums where I might be able to
discuss this please?

Regards,

Andrew Marlow

Deanna Earley

unread,
Jan 16, 2012, 7:28:09 AM1/16/12
to
How do they fail?
Is there an error from whatever "start process" function you're using or
an exit code?
What does process monitor show?
Are all the paths set correctly?

--
Deanna Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

Andrew

unread,
Jan 19, 2012, 3:04:17 AM1/19/12
to
On Jan 16, 12:28 pm, Deanna Earley <dee.ear...@icode.co.uk> wrote:
> On 10/01/2012 07:35, Andrew wrote:
>
> > I have written a windows service that launches other programs. I find
> > that certain programs I launch that I dont have the source for, do not
> > launch successfully unless I launch them via an intermediate batch
> > file. Does anyone have any ideas on whny this might be?

> How do they fail?

Err, yes, you're right, I should have given more detail. The process
creation works, I get a pid back, but the process then exits
immediately. It is supposed to be a long-running process that writes
to its own logfile. The logfile does not get written so it is failing
VERY early on. With no logging it is very hard to see why.

> Is there an error from whatever "start process" function you're using or
> an exit code?

No. CreateProcess actually works. It is just that the process exits
right away before it has the chance to do any work at all.

> What does process monitor show?

The process is too short-lived to reveal anything.

> Are all the paths set correctly?

Yes. This can be proved by making it launch a DOS batch file that just
has the set command to dump all environment variables, including PATH.

I managed to make my launching program work. I use Poco, the portable
multi-platform C++ foundation class library. It has a class, Process,
for launching processes. On Windoze this calls CreateProcess. I
changed the code so that it sets inheritHandles to FALSE and the
options flags to CREATE_NO_WINDOW. This makes it work. This also
demonstrates that the environment is correct, that the right
environment variables are there, that it can load all the DLLs etc.
However, I am not sure this hack is right for Poco, since Poco offers
I/O redirection in its launch method. I have a feeling that
inheritHandles needs to be TRUE for that to work. I need to find out
more about what happens with I/O when a launched process does not
inherit the handles. Suppose it writes to std::cout. Where does the
output go?

>
> --
> Deanna Earley (dee.ear...@icode.co.uk)
> i-Catcher Development Teamhttp://www.icode.co.uk/icatcher/
>
> iCode Systems
>
> (Replies direct to my email address will be ignored.
> Please reply to the group.)

Many thanks for your reply, I really appreciate it :-)

Deanna Earley

unread,
Jan 19, 2012, 5:24:37 AM1/19/12
to
On 19/01/2012 08:04, Andrew wrote:
> On Jan 16, 12:28 pm, Deanna Earley<dee.ear...@icode.co.uk> wrote:
>> On 10/01/2012 07:35, Andrew wrote:
>>
>>> I have written a windows service that launches other programs. I find
>>> that certain programs I launch that I dont have the source for, do not
>>> launch successfully unless I launch them via an intermediate batch
>>> file. Does anyone have any ideas on whny this might be?
> >
>> Is there an error from whatever "start process" function you're using or
>> an exit code?
>
> No. CreateProcess actually works. It is just that the process exits
> right away before it has the chance to do any work at all.
>
>> What does process monitor show?
>
> The process is too short-lived to reveal anything.

Anything or "anything of interest"?

Process Monitor logs everything the process does so will report any
failures. You can try comparing it to a working run.

--
Deanna Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
0 new messages