本帖最后由 aries215 于 2021-8-31 20:14 编辑
查询注册表获取SID是最简便的,环境依赖最少,不用生成中间文件。- @echo off
- for /f "delims=\ tokens=2" %%a in ('reg query "HKU" /k /f "S-1-5-21-" 2^>nul') do (set "usid=%%~a" && goto end)
- :end
- echo %UserName%:%usid%
- pause
复制代码 还有键值:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI |