How to run PHP as an Administrator
Posted by: aaronkreider (---.hsd1.pa.comcast.net)
Date: October 24, 2013 10:15PM

I want to run PHP (5.2.5) on WAMP as the administrator user on Windows 8. Currently when I run exec(whoami) it returns "nt authority/system". I want it to run as the Administrator (or more precisely aaron-desk/administrator) so that I have the correct permissions to run a command line program (TileMill).

I have tried running WAMP as the administrator, but PHP still runs exec() under the system username.

I have also tried setting up services.msc to run the wampapache and wampmysqld services as Administrator (instead of Local System), but when I do this they fail to run. There is a login error. I have an empty Administrator password but it does not work for these services when I apply it in services.msc.

I am running Windows 8 Pro as the administrator.

How can I do this?



Edited 1 time(s). Last edit at 10/28/2013 08:22PM by aaronkreider.

Options: ReplyQuote
Re: How to run PHP as an Administrator
Posted by: Otomatic (Moderator)
Date: October 25, 2013 10:30AM

Hi,

How to start services "wampapache" and "wampmysqld" in Windows "standard" session but with administrator rights.

[forum.wampserver.com]

Sorry, only in French

It works with all versions of Windows 7 and Windows 8

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: How to run PHP as an Administrator
Posted by: aaronkreider (---.hsd1.pa.comcast.net)
Date: October 28, 2013 08:38PM

Thanks. I tried that method and it didn't help my situation.

I have two ideas
1. Run wampapache as aaron-desk/administrator.
2. Change the TileMill permissions in windows 8 to run different. It uses node.js so I might want to change the permissions for that.

I found this reference to nt authority:
NT Authority\SYSTEM a.k.a LocalSystem account is a built-in Windows Account. It is the most powerful account on a Windows local instance (More powerful than any admin account).

It is strange that such a powerful account would not be able to do what I want.

Options: ReplyQuote
Re: How to run PHP as an Administrator
Posted by: aaronkreider (---.hsd1.pa.comcast.net)
Date: October 28, 2013 11:22PM

It turns out that modifying the environmental settings fixed this problem. I set the environmental settings to the ones used by the other user and now it works. It wasn't a permissions problem.

Options: ReplyQuote
Re: How to run PHP as an Administrator
Posted by: cdt2u (---.dsl.sta.abo.bbox.fr)
Date: May 10, 2014 05:33AM

aaronkreider Wrote:
-------------------------------------------------------
> It turns out that modifying the environmental
> settings fixed this problem. I set the
> environmental settings to the ones used by the
> other user and now it works. It wasn't a
> permissions problem.


Thank you so much !!!

I've just been spending the night to resolve this nightmare. Your last post gave me the key.


So I'm sharing my issue in hope it could help someone else as your answer did with me.
I'm using Windows 8.1 / Wampserver 2.4 (php 5.4.12 / apache 2.4.4) / Code Blocks / MinGW all in x64


My problem was the following: I wanted to run an c++ executable through the exec() function in php. Problem was that I didn't get any output or error. Really weird.

At first, I did some tests :
- I simplified my executable so that it only displays the output "Hello World" when executed
- The other classic commands such as dir, whoami or ping did work through the exec() function in php
- When using the command line, my c++ executable worked perfectly

So it was not a problem of the executable not working nor the exec() function not enabled...


The long night journey began then, and I flipped through all forums I could get with all set of keywords possible...
- Some suggested to reinstall the c++ compiler in x32 (which I really didn't want to and finally didn't have had to),
- others said to redirect output from sdterr to sdtout.
- or using system(), shell_exec(), passthru(), proc_open() instead of exec()
- or using the program SetACL to set the user as admin on wampserver services (which didn't do anything at all for me)
- or changing the services' user when starting wampserver (which would then refuse to launch)
- or launching wampserver as an administrator
Neither of these solutions worked for me... So I was really going to lay my arms down...

Finally, I stumbled upon your post, looked to the environnement variables... Actually my MinGW and CMake paths were set for me but not for the system. So since Wampserver starts as the Local System, it didn't have the path for MinGW and CMake.

I changed the settings, crossed my fingers, refreshed my page and I couldn't believe my really-tired eyes, the output was there:
"Hello World!"

I was really happy... And it's true, now a new world is opening to me! I can run my c++ executable through my php... Such promising feats smiling smiley

Thank you again!!!!

Options: ReplyQuote


Sorry, only registered users may post in this forum.