In the last days i was tying to code something in PHP to popup a CMD windows and this CMD windows have a command like "ping google.com" and process it
i don't need the PHP code to read the result , i only want it to run it
i tried some thing like
<?php
exec('C:\Windows\System32/cmd.exe ping google.com');
<?
but no result (i don't know if it run it in background )
so i read this and i founded many ways but nothing worked
My OS is windows and thanks alot for all :)
Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.
After installation of PHP, we are ready to run PHP code through command line. You just follow the steps to run PHP program using command line. Open terminal or command line window. Goto the specified folder or directory where php files are present.
PHP's Command Line Interface (CLI) allows you to execute PHP scripts when logged in to your server through SSH. ServerPilot installs multiple versions of PHP on your server so there are multiple PHP executables available to run.
the answer is
i searched alot to find it :))
<?
execInBackground('start cmd.exe @cmd /k "ping google.com"');
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With