Reply
Exec/system problem
Old 04-16-2008, 08:44 AM Exec/system problem
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Hello

I would like to launch exe/bat file via php. I have windows Vista, php5, apach2



When I use

Code:
exec('dir > output_aaa.txt');

everything is ok , but when I try

Code:
system('notepad.exe')

it doesn't work at all. Scripts starts executing but it never stops and notepad(in this case) doesn't open.

Does anyone have idea what to do? Maybe some config in httpd.conf?

I'm looking forward to your help
__________________
Seo Link Directory | Kurs C++ | Forum C++
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
When You Register, These Ads Go Away!
Old 04-16-2008, 09:44 AM Re: Exec/system problem
Ultra Talker

Posts: 481
I don't use Apache on Windows myself, but I think I've read about this before: essentially, Apache is running as the SYSTEM user which does not have the rights to load anything on the screen.

From what I can remember, you need to tell Windows to run the service as the user whose GUI is being run (and whose GUI the program will eventually load on).
__________________
Free PHP Obfuscator
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 04-16-2008, 10:12 AM Re: Exec/system problem
Super Spam Talker

Posts: 888
TwistMyArms answer is correct!

You could get round this by writing a windows app in C, or batch or whatever you like.. have it go look for a lock file every so often, if it exists, open your notepad.exe... the php script would then just have to create the lock file
__________________
Xyber Wars Free Browser Based MMORPG | Over 150,000 free guitar, bass , drum tabs & lyrics | free, fast guitar tab | cakephp tutorials
-- Need PHP/MYSQL Code written or Installed? Hire Me.
Sir P is online now
Reply With Quote
View Public Profile
 
Old 04-16-2008, 01:48 PM Re: Exec/system problem
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Thanks for your help but I think I'll have to give up.

I use the following script:

Code:
<?php
   error_reporting(E_ALL);
   chdir('blabla');

   $command = 'psexec  -u marcin -p mypassword d:\www_wamp\blabla\odt.bat d:\www_wamp\blabla\archive.odt >NUL 2>&1';   
   exec($command);
?>
When I use string assign to $command variable not in PHP but in CMD it works fine, but when I launch PHP script the situation is the same as earlier - the script never stops.

Similar situation is when I use:

Code:
$command='psexec  -u marcin -p mypassword  dir >hhh.txt';
as command in PHP.
__________________
Seo Link Directory | Kurs C++ | Forum C++
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Reply     « Reply to Exec/system problem
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12451 seconds with 12 queries