如何使用命令行在 Windows Server 2008 R2 中将用户添加到文件权限

How to add user to file permission in Windows Server 2008 R2 with Commad Line

我们正在使用 Windows Server 2008 R2 和 Plesk。我们的网站是使用 Php CodeIgniter 框架开发的。

我们无法从上传的子域读取文件,需要将主域用户名设置为上传的文件,所以我可以手动完成,但我们需要使用命令行来完成,这样我们就可以在 Php.

有什么帮助吗?谢谢

我自己找到了答案,给你;)

$file_url = "C:\inetpub\vhosts\domain.com\httpdocs\sub.domain.com\uploads\image.jpg";
$group_username = "example_username";
exec('icacls '.$file_url.' /grant '.$group_username.':f ');

原始版本:

exec("icacls C:\inetpub\vhosts\domain.com\httpdocs\sub.domain.com\image.jpg /grant example_username:f");

就是这样。此代码将提供 完全控制.

查看更多; https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/icacls

如果有用就点个赞:)