Question

when I run exec('C:\execute\batfile.bat'); it works when my xampp is installed in C:

but when I move my codes in another server the xampp there is installed in D:

so my code exec('D:\execute\batfile.bat'); fails and doesn't show any errors when I test in browser.

Please help on how to run a bat file not saved in C:

Thank you so much

Was it helpful?

Solution

thanks for your suggestion and solutions :)

I follow the suggestion of @preet sangha and find "ERROR: The parameter is incorrect".

Then I researched more on what is the cause of incorrect parameter. Then I stumble upon the answer of juan at laluca and ernestokarim in http://php.net/manual/en/function.exec.php. And I follow the answer of ernestokarim

Start > Run > "services.msc"

Search the Apache Service, right click and select Properties.

You will see two radio buttons, check the first if it isn't, and then check too the check box below. Under Log On Tab

Now restart Apache

I realize that for some reason when xampp is installed in C, function exec works fine but when you installed it in other drive it doesn't because of some permission issues. The above steps solve my dilemma :-)

OTHER TIPS

Try echoing the output, maybe you're just missed something inside the bat file and it's not a php problem

echo system("D:\execute\batfile.bat");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top