Results 1 to 3 of 3

Thread: PHP: Execute cacls.exe

  1. #1
    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?

  2. #2
    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

  3. #3
    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);
    ?>

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,560,566.02159 seconds with 17 queries