I have a question regarding Windows Task Scheduler
I have everything running normally. Open the browser and run the php code.
But then there is the possibility of closing the same page in the end alone?
I have a question regarding Windows Task Scheduler
I have everything running normally. Open the browser and run the php code.
But then there is the possibility of closing the same page in the end alone?
If you need to run a php script automatically, call it by the line instead of invoking IE with the desired page / script, so you do not worry about closing the browser when processing ends the% will be closed.
In your bat call it php like this:
php -f "C:\caminho_completo\script_automatico.php"
For the command to be recognized in the DOS terminal it is necessary to add the path of the php executable to the variable cmd
of windows.
This can be done through the shortcut win-key + break / pause or right click on (my) computer > properties > advanced system settings, advanced tab > environment variables. Create a new call PATH
its value is the folder where the .exe of php is. Doing this add PHP_HOME
to PHP_HOME
at the end put: PATH
.
To test open a new cmd and type ;%PHP_HOME%;
if everything is right it should display the php version.
You can make an event by calling a batch, in this batch you control the behavior:
taskkill /f /im chrome.exe >nul 2>nul
start "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http://localhost/
taskkill /f /im chrome.exe >nul 2>nul
When you want to close the window you can do the following:
echo "<script>window.close();</script>";
But depending on your application, response from @ lost would be better to call PHP in your bat that way :
php -f "C:\caminho_completo\script_automatico.php"
To make system calls PHP has the system()
function, read the documentation :
string system (string $command [,int &$return_var])