icacls giving an error message "The System cannot Find the File Specified" When executed on folder
- by someshine
I have a remote share in windows 7 and accessing the same share from windows 2008. I have a small script in PHP which denys the read permission on a folder in a share and again give the full permissions on that folder in the share and deletes that folder .Here the Problem is "Denying the Read Permission is working fine and again assigning full permission on that folder in the share is not working .Iam using icacls for assigning all the permissions .When i try to assign the Full permission on that folder in the share It is giving error message "The system cannot find the file specified ".When we output the command from the script and execute it on commandline it is working fine .Why is it not working from my PHP script .Please Advise me
$dir_name = "testdir";
$share_path = "\\SERVERABCD\myshare";
mkdir($share_path."\$dir_name");
$path_escaped = '"'.$path.'"';
$user = getenv('USERNAME');
$cmd = 'icacls ' . $path_escaped . ' /deny ' . $user . ':(OI)(CI)(R)';
exec($cmd);
//From This statement it is giving error message "the System cannot find the file Specified"
$cmd = 'icacls ' . $path_escaped . ' /remove:d' .' '. $user;
exec($cmd);
$cmd = 'icacls ' . $path_escaped . ' /grant ' . $user . ':(OI)(CI)(F)';
exec($cmd);
if(file_exists($share_path."\$dir_name")){
rmdir($share_path."\$dir_name");
}
?
//This Scripts Works Fine For Files on shares where as it says "The System cannot find the file specified" for folders from second $cmd statement .