English 中文(简体)
Cacls,Windows 7, full freedoms, local name
原标题:Cacls, Windows 7, full permissions, local names

我需要使用(在7赢利时解释的)卡片对双胞胎给予充分的准入许可。 在我看来,我不得不使用地方化用户名称和团体名称。 例如:

cacls foldername /T /E /C /G Users:F

这给我留下了错误“没有在账户名称和安全身份证之间绘制地图”。 接下来的指挥工作是罚款(白俄罗斯的用户= П л а а т т т)。

cacls foldername /T /E /C /G Пользователи:F

无论使用何种系统语言,怎么能允许对文件夹进行充分许可?

最佳回答
问题回答

该法典将把Y/N和USERS(或任何SID)本地化,并在预期的目录中执行CACLS,解决原始问题。

@echo off
  rem https://learn.microsoft.com/en-US/windows-server/identity/ad-ds/manage/understand-security-identifiers
  rem SIDs:  S-1-5-32-545 Users;  S-1-1-0 Everybody;  S-1-5-32-544 Administrators
  rem   S-1-5-7 no logon;  S-1-5-11 Authenticated Users;  S-1-5-18 System;  S-1-5-10 Self

set userSID=S-1-5-32-545&  rem USERS sid
set dirName=%TEMP%TEST

  rem https://stackoverflow.com/questions/20892882/set-errorlevel-in-windows-batch-file/77643084#77643084
  rem try setting errorlevel 1 doesn t work on win9x: verify other 2>nul
  REM set errorlevel 1, to check next command
<nul find ""
  REM enableExtensions/delayedExp to get !varNm! value on execution
setlocal enableextensions enabledelayedexpansion
if NOT ERRORLEVEL 1 goto :WinNew
  echo *** OLD OS: Can t enableextensions ***
  ver
  goto :FIN
:WinNew

  REM Get local language Yes/No/All letters {to answer prompts}
  REM https://www.dostips.com/forum/viewtopic.php?p=63518#p63518
set PromptLine=
  rem create dummy file [in w9x]: echo x >"%TEMP%yesnoall#.tmp" >nul
copy /y nul "%TEMP%yesnoall#.tmp" >nul
  rem capture overwrite prompt after "#" ie: ".tmp? [Sí/No/Todos]:"
for /f "tokens=2* delims=#" %%A in (  ^<nul copy /-y nul "%TEMP%yesnoall#.tmp" 
  ) do set PromptLine=%%A
  rem remove dummy file
del "%TEMP%yesnoall#.tmp"
  rem For testing complicated case [russian], uncomment next line
rem set PromptLine=.tmp [Yes (a?)/No (b??)/All (c??)]:
  rem remove spaces for russian
set PromptLine=%PromptLine: =%
  rem parse simple case get: A,B,C else complicated case with brackets and parenthesis: A,C,E
for /f "tokens=2-7 delims=[(/)]" %%A in ( "%PromptLine%"
  ) do if "%%~E" == "" ( set lang_yes=%%A& set lang_no=%%B& set lang_all=%%C
  ) else ( set lang_yes=%%A& set lang_no=%%C& set lang_all=%%E
)
  rem Extract first char
set lang_y=%lang_yes:~0,1%& set lang_n=%lang_no:~0,1%& set lang_a=%lang_all:~0,1%
  rem Display results
echo %lang_yes%, %lang_no%, %lang_all%
echo %lang_y%, %lang_n%, %lang_a%

  rem https://stackoverflow.com/questions/9113206/cacls-windows-7-full-permissions-local-names
  rem https://superuser.com/questions/1176622/regardless-of-windows-language-how-can-i-make-the-icacls-command-set-a-folder-t
  rem generate temp sid2user.VBS script to get local language userSID name
( echoSet objWMIService = GetObject("winmgmts:\.
ootcimv2"^)
  echoWscript.Echo objWMIService.Get("Win32_SID.SID= %userSID% " ^).AccountName
) > "%TEMP%sid2user.vbs"
  rem set lang_user to userSID local language name
for /F "delims=" %%i in ( cscript -Nologo "%TEMP%sid2user.vbs" ) do set lang_user=%%i
  rem remove temp vbs file
del "%TEMP%sid2user.vbs"
echo "%lang_user%":F

  rem set permissions in local language
echo %lang_y%|cacls "%dirName%" /t /l /c /G "%lang_user%":F

:FIN
pause




相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....