Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-05-2009
Member
 
Join Date: Feb 2008
Posts: 1,337
PHP: Execute cacls.exe

I would like to know how to change the file permissions of a directory on Windows Home Server using PHP script? I read some where on Internet about CACLS command. But I don't know how to use CACLS command in PHP script. Can you help me to assign a new file permissions to certain directories?
Reply With Quote
  #2  
Old 30-05-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
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
Reply With Quote
  #3  
Old 30-05-2009
Member
 
Join Date: May 2008
Posts: 685
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);
?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "PHP: Execute cacls.exe"
Thread Thread Starter Forum Replies Last Post
How to execute a program in C#? Lauren Benjamin Software Development 4 26-12-2010 01:11 AM
Windows 7 + CACLS = Can't access drive Ambak Operating Systems 5 19-06-2010 04:50 AM
How to execute Server.Execute function in ASP.NET (C#) RasMus Software Development 3 25-09-2009 12:30 PM
Execute xp_cmdshell Conner Software Development 3 13-07-2009 03:25 PM
Can not execute .vbs files RichiRich Software Development 3 10-06-2009 12:44 PM


All times are GMT +5.5. The time now is 10:12 PM.