Click to See Complete Forum and Search --> : php 4.3.8, windows 2000 server, permission problems
chriswheat
11-29-2004, 08:38 PM
Hello,
I am running php 4.3.8 on a windows 2000 server, and php works and mysql works however I can not get php to run a cmd.
On the server if I go to start, then run, then type:
net stop MyAdapter
this will stop the windows service "MyAdapter"
However when I try this php script:
shell_exec("net stop MyAdapter");
or
exec("net stop MyAdapter");
This is the error I get:
Access is denied.
Content-type: text/html
X-Powered-By: PHP/4.3.8
How do I give php permission to run cmd's ?
Many thanks
Chris
biggus
11-30-2004, 04:48 PM
I had that same problem when trying to call a Verisign exe file. The way I handled it was to build a bat script to call the executable and have PHP call the bat script using parseQuerystring(shell_exec("$path_to_bat")). I used the parseQuerystring to process the return info.
If I recall correctly, the problem had something to to with bits. A 16 bit process can't call a 32 bit process, or something like that. (Or was it an 8bit can't call a 16bit?) Anyway, the bat script worked like a charm for me.
Let me know how it works out.
Biggus
chriswheat
11-30-2004, 05:13 PM
I can run regular commands, like help, dir, ect.
I can also run a .bat file that uses gnupg to encrypt a file, however I can not do net start/stop.
I have tried running net start/stop using it like
shell_exec("net start MyService")
and
shell_exec("net start 'MyService'")
and
shell_exec("start.bat")
-----
start.bat has:
net start MyService
-----
None of these work, so it appears to be a problem only with the net start/stop commands???
I have spent hours googling this and can not figure it out.
:( :confused: :(
biggus
12-01-2004, 12:06 PM
I don't know. I don't have access to a Windows server anymore, so I can't test. I'd like to see what you end up doing, though.
If I see anything that may help, I'll post it.
Good luck.
Biggus
chriswheat
12-01-2004, 12:25 PM
I found out that it has to be a security setting somewhere, because I can use php command line, from the start run.
C:\PHP\php.exe C\DIR\test.php
and the exec() works perfect, however if I put the test.php in the
wwwroot and try the php command line:
C:\PHP\php.exe C:\wwwroot\test.php
the same function does not work.
We have a sybase DB that recieves about 200,000 records a month, and I was going to use this script to stop the service that puts the records into the db, then cleanse the data and move it to mysql for reporting, then start the service agian.
This is something I can have run once an hour so the php command line will fix my problem.... I would still like to figure out why I can run cmd's from wwwroot with the exception of net stop/start?:confused:
Thank you for all your help!
Chris
biggus
12-01-2004, 01:03 PM
I take it you're going to schedule it with the schedule tool?
Not to dissuade you from using this forum, but maybe try on forums.devshed.com to see if one of those brainy bastards knows the answer. If you do find out, please let me know what the deal is.
Thanks,
Biggus
chriswheat
12-01-2004, 01:15 PM
Yes I wrote a batch file the does the
c:\php\php.exe c:\dir\test.php
Then used windows scheduler.
I will post this on
forums.devshed.com
and see what they come up with... I let you know the verdict.
Chris
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.