0

I have a strange problem.

I am working with Windows software that is written by me, and a third party.

The third party has created an installer. This installer runs requests admin rights programmatically. This installer also installs Apache as a Windows Service. Because the installer is running with admin rights, we expect the Apache Windows Service to run with admin rights.

The problem that we are seeing is that we get different results from a php script running on Apache, depending on how Apache is launched.

If Apache is running as the Windows Service, installed via the installer mentioned above we get the wrong result. If Apache is started from the cmd prompt (which starts as User Administrator) then the php script gives the correct result.

Can anyone suggest what could be going wrong?

NB. The php script is running CutyCapt.exe (an website to png capture utility).

patchwork
  • 1,161
  • 3
  • 8
  • 23
  • The first thing to do is to check what account the service is configured to use. You can do this using `sc` on the command line or with the GUI administrative tool `services.msc`. – Harry Johnston Apr 18 '14 at 00:10

3 Answers3

1

The Apache Service, regardless of how it was installed, always start under the "LocalSystem" account (unless you change it afterwards).

On the other hand, when you start the Apache process via the command-line, it starts under the same account you are running the command-line (cmd.exe) with.

My guess is that either LocaSystem has no access to the Desktop which this app might require, or it can't execute the exe... Check Apache's and PHP's error logs. Also check Windows Event Logs.

rightstuff
  • 6,412
  • 31
  • 20
0

The installer needs admin rights in order to make modifications to the system (e.g. write to the HKLM registry keys shared by all users). It does not automatically imply that the installer configures the services being installed to run under an account with admin rights.

There is one big difference between services and "normal" applications started from the command line and it is that services don't have access to a "screen" where they might show some messages. And services don't have access to some usual places, like user's storage for temporary files etc. as they run in an environment with sort-of "no user logged in".

What exactly is the problem can not be guessed without knowing more precisely what is the "wrong result" that you receive.

This Starting a Windows service in an interactive session answer may provide some additional hints.

I'd first check phpinfo() and the environment variables and then check requirements of the CutyCapt.exe. e.g. the fact that user's temporary file storage is not accessible by default and registry values can not be read freely was a problem I've already seen

For an Windows+Apache+MySQL+PHP installer with 0-problems I'd recommend Bitnami's WAMP stack https://bitnami.com/stack/wamp, self contained, portable style

Community
  • 1
  • 1
xmojmr
  • 8,073
  • 5
  • 31
  • 54
0

I upvoted rightstuff's answer. One additional thing to try. Go to Control Panel => Administrative Tools => Services. (Or just type "services.msc" after pressing WIN+R to bring up the Run dialog.)

From the Services management screen, right click on the Apache service. Then go to to the LogOn tab. Specify the account and password you want the service to run under.

selbie
  • 100,020
  • 15
  • 103
  • 173