Skip to content
PHP Logo

Is it possible to execute PHP commands directly within a .bat file on Windows without relying on php-cli?

It is not possible to execute PHP commands directly within a .bat file on Windows without relying on php-cli. However, you can create a separate PHP script file and call it from the .bat file using php-cli to execute the PHP commands.

php
// php_script.php
<?php
echo "Hello, World!";
?>

// batch_file.bat
@echo off
php -f php_script.php