use*_*666 9 windows powershell network-share
使用 Powershell 如何创建共享并设置访问权限。
例如如下
这应该可以解决问题:
net share "Public=c:\shares\foo" "/GRANT:Users,READ"
Run Code Online (Sandbox Code Playgroud)
当然,您需要使用管理权限启动 PowerShell,具体取决于您在何处/如何执行此操作。
使用 Win32_Share 创建方法。例子:
(Get-WmiObject -List -ComputerName . | Where-Object -FilterScript
{$_.Name -eq "Win32_Share"}).InvokeMethod("Create",
("C:\FolderToShare","ShareName",0,100,"Share description"))
Run Code Online (Sandbox Code Playgroud)
您可以在 MSDN 上找到此方法的文档。
uint32 Create(
[in] string Path,
[in] string Name,
[in] uint32 Type,
[in] uint32 MaximumAllowed,
[in] string Description,
[in] string Password,
[in] Win32_SecurityDescriptor Access
);
Run Code Online (Sandbox Code Playgroud)
参数:
有关如何设置访问权限的详细信息,请参阅 MSDN 上的此页面:Win32_SecurityDescriptor Class。本文也是一个很好的起点:WMI 任务:文件和文件夹。
归档时间: |
|
查看次数: |
41907 次 |
最近记录: |