tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: svn commit: r1567742 - /tomcat/tc7.0.x/trunk/bin/service.bat
Date Sat, 15 Feb 2014 20:13:13 GMT
2014-02-15 23:03 GMT+04:00 Konstantin Prei├čer <>:
> Hi,
>> -----Original Message-----
>> From: Konstantin Kolinko []
>> Sent: Saturday, February 15, 2014 6:50 PM
>> To: Tomcat Developers List
>> Subject: Re: svn commit: r1567742 - /tomcat/tc7.0.x/trunk/bin/service.bat
>> 2014-02-12 23:50 GMT+04:00  <>:
>> > Author: markt
>> > Date: Wed Feb 12 19:50:29 2014
>> > New Revision: 1567742
>> >
>> > URL:
>> > Log:
>> > Fix a secondary issue identified in
>> > Install the service with a single call to the .exe rather than three calls.
>> >
>> Major:
>> ---------
>> service.bat install  is broken by this change on Windows 7.
>> The symptom is that none of "PR_" variables set to pass classpath, jvm
>> etc. to  Tomcat7.exe
>> appear to have any effect.
>> It is odd. I suspect that it might be a bug in commons daemon procrun.
> Hmm, I think the problem here is another one. Actually, I think this change didn't break
service.bat. When opening a cmd.exe as administrator and use "service install", it still works
with 8.0.4 and 7.0.52.
> I think the problem is, that when a process is elevated by UAC (from normal user-rights
to admin-rights), the environment variables of the parent process are lost. My guess would
be that the process cannot be a "real" child process of the parent when it has different access
rights so it cannot inherit the environment variables (although SysInternals Process Explorer
still shows the process as child of cmd.exe).
> I verified this by creating a simple C# application that outputs an environment variable:
>             Console.WriteLine("%TEST%: " + Environment.GetEnvironmentVariable("TEST"));
>             Console.WriteLine("%ComSpec%: " + Environment.GetEnvironmentVariable("ComSpec"));
> When changing the app's manifest so that it requires administrative access:
>     <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
> Then when starting this .exe from cmd.exe, environment variables set in cmd.exe ("TEST",
"ComSpec") were lost.
> The problem happens also with earlier versions of Tomcat, when running service.bat from
an non-elevated cmd.exe and then clicking "Yes" on the UAC dialog. (E.g., the service in the
service explorer then shows "Tomcat8" instead of "Apache Tomcat 8").
> Unfortunately, when writing the comment for bug 56079, I did not check if the service
is installed correctly, but only check for the message displayed in the console like "The
service Tomcat7 has been installed successfully", so I did not notice the problem.
> I think currently the only way to correctly install Tomcat as a service when using service.bat
is to run cmd.exe as administrator.

Thank you.
You are right.

If I create a batch file like the following:
cd \temp.2014-02-15\apache-tomcat-7.0.52\bin
set "JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_51"
call service.bat install

and use "Launch as administrator" on it in Explorer,  the service is
installed successfully,

(With exception stdoutput/stderror settings. Those remain as empty.
The service starts successfully, but stdout/stderr are not caught to a

So this did not work earlier either. The only regression in 7.0.52 is
stderr/stdout one.
There were several reports on users@. This explains it.

I'll add this to Bugzilla.

> If it is possible to provide the values as arguments instead of environment variables,
then I think it should work when running service.bat from a non-elevated cmd.exe


Best regards,
Konstantin Kolinko

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message