I have run exec() method in windows using the following script:
<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>
A simple way to see what works and what doesn’t is to open the command line on the operating system.
On windows, you can access the command line by hitting the windows key + ‘R’, then typing ‘cmd’ and hitting enter - that’ll open up command prompt.
On Linux it depends on your distro, but assuming you’re using one with the default Gnome menu, it’ll usually be under ‘Applications’ : ‘Accessories’ : ‘Terminal’.
PHP’s exec function simulates you typing the command into that terminal.