Re: PHP: Execute cacls.exe
To launch an external program, use the exec function.
Description
exec — Executes an external program
Syntax
Code:
string exec (string $command [, array &$output [, int &$return_var]])
where,
command: The command that will be executed.
output: If the output argument is present, then the specified array will be filled with every line of output from the command.
return_var: If the return_var argument is present along with the output argument, then the return status of the executed command will be written to this variable.
Example
PHP Code:
<?php
echo exec('whoami');
?>
This gives the username that owns the running php/httpd process
Re: PHP: Execute cacls.exe
cacls is a small Windows utility that allows you to display and modify access control on your files and folders. You can use this utility with the exec function using the PHP script as follow:
PHP Code:
<?php
$cmd = "c:\windows\system32\cacls.exe ".$filepath." /e /g ".$username.":F";
echo $cmd;
$result = exec($cmd);
?>