Jump to content

Recommended Posts

Hi, If anyone can help me please?

 

I would like to execute a batch file from a php script. I have simply got the following code at the moment:

 

echo exec('load.bat');

 

after submission the page is doing something (loading) but nothing executes. The batch file loads fine when i click it manually!

 

any ideas please? thanks!  :)

Link to comment
https://forums.phpfreaks.com/topic/89561-exec-a-batch-file-from-a-php-script/
Share on other sites

Hi,

 

Thanks, i removed the echo, its now looking like:

 

exec('c:\load.bat');

 

The batch file manually is executing an .exe! the php script seems to be loading the batch file but for some some odd reason its crashing the program.

 

Any ideas?

 

cheers

at the moment its all testing a technique, ive got everything local.

 

To clear up the problem, the batch file (load.BAT) contains the following:

 

cd "C:\Documents and Settings\methtical\Desktop\\Software"

Serv.exe

 

This fires the Serv.exe up when i click on the load.BAT perfectly. What im doing as a test is to send a command from php that can do it for me.. i.e exec('C:\load.bat');

 

Eventually im looking at a web interface that wont specifically execute an exe but to execute batch files in general.

 

If anyone can help, it would be much appreciated! thanks!  ;D

How long does Serv.exe take to complete? Thats how long it will take before exec will return control to your script.

 

Also, I think you'll find any program which attempts to open a window will not run. The apache process simply doesn't have permissions to do this. (At least on Linux anyway)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.