Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a batch file

Status
Not open for further replies.

Sarky78

Programmer
Joined
Oct 19, 2000
Messages
878
Location
GB
Hi, all

I am having problems executing a batch file on a win2k server machine running PHP 4.2.3. When i just double click the batch file from an explorer window, it runs and does what it is meant to do. The problem is that i need to be able to do this on demand, so clicking on a file is not an option!

When i run the code on a win2k pro box, running PHP 4.3.2 it does exactly what i want it to do, but running it on the server machine it just sits there doing nothing! When i run it on a XP Pro box, i get "Can't fork to...." whatever the hell that means!

this is the bit of code:

exec("search_generator.bat");
which in turn goes off and executes a program!

Any ideas?

TIA

Tony
 
You're going to have to explicitly invoke the command interpreter. Win32 knows to invoke the command interpreter from either registry settings used by the GUI or builtin functions of an existing command interpreter instantiation.

Try something like:

exec ('command /c search_generator.bat');



Want the best answers? Ask the best questions: TANSTAAFL!
 
Cheers, will give that a try 2morrow, weird thing is though that it works perfectly on my Win2k Pro workstation, but not on the win2k Server platform

Weird!!

Thanks will let you know how i get on!

Tony
 
There are several reasons that's possible... there's also the possibility of permissions being off and the user which your webserver is running as not having the permissions to execute the file.

Best of luck.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top