Jump to content

Featured Replies

Posted

Hi.

 

I want to know how can I set an environment variable with the command line permanently and per user.

 

After some searching, I found the "setx" command, but after a lot of experimentation, I never found something that REALLY works.

 

Let me describe the actual reason I want to do that too - I have IIS7 running and PHP as CGI (I'm thinking of moving to FCGI, but the same problem would persist there anyway, so...) and I want to allow users to have their own php.ini.

 

As by best security practices, PHP already runs in a different application pool with a different identity, and each user/identity already has appropriate rights on. So, in order to allow users to have their own php.ini (whatever they decice, I can still top the crutial things like rights and bandwidth from within IIS), the easiest and most reliable way (in my POV) is to modify the PHPRC environment variable to contain both their folder and the common configuration folder as a latter choise. However, I need to do this automatically upon registration (from PHP), so the best way is with this command.

 

The command that got me close enough was

 
setx /S MM-SERVER /U TEST /P TEST PHPRC D:\Domains\example.comD:\conf

"MM-SERVER" is the computer name of my server. Localhost also works (as in "it doesn't give an error"). The credentials are all correct, and the command says it's successful. But when I open up phpinfo(), I still see the old global value of PHPRC, not the per-user one (and yes, I'm sure PHP is running as that user).

 

Any ideas as to what may I have done wrong with the command? Any better one? Any alternative approach that can be realized within PHP? I'd really like not to use ASP(.NET). I love IIS7, but I still don't like ASP(.NET).

Guest
Reply to this topic...