net share 共享 和 NTFS 权限问题
近日使用net share share1=e:\myshare 共享时,当E:是NTFS格式时,访问共享文件夹时提示访问拒绝。原来是因为NTFS的权限设置问题,解决方法如下:
从Microsoft下载subinacl工具:
http://www.microsoft.com/downloads/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&displaylang=en
建立共享后,使用如下代码:
subinacl /file e:\myshare /grant="Everyone"=F
即OK
BTW:
DWORD ExecuteAndWaitForCompletion ( LPSTR pszCmd)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
MSG msg;
BOOL bRes;
DWORD dwCode = 0;
ZeroMemory ( &si, sizeof ( STARTUPINFO));
si.cb = sizeof ( STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
bRes = CreateProcess ( NULL,
pszCmd,
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi
);
while ( WAIT_OBJECT_0 != MsgWaitForMultipleObjects ( 1,
&pi.hProcess,
FALSE,
INFINITE,
QS_ALLINPUT
)
)
{
while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE))
{
DispatchMessage ( &msg);
}
}
GetExitCodeProcess ( pi.hProcess, &dwCode);
CloseHandle ( pi.hProcess);
CloseHandle ( pi.hThread);
return ( dwCode);
}
如以下方法使用:
ExecuteAndWaitForCompletion("cmd.exe /c net share Logger$=\"C:\\Program Files\\Logger\"");