I need a way to store the current SID of the user in a variable, I tried many options:
setlocal enableextensions
for /f "tokens=*" %%a in (
'"wmic path win32_useraccount where name='%UserName%' get sid"'
) do (
if not "%%a"==""
set myvar=%%a
echo/%%myvar%%=%myvar%
pause
endlocal
Does not work.
wmic path win32_useraccount where name='%UserName%' get sid
should return 3 rows, and I need a second one, which is stored in a variable.
Can someone fix my script?
Edit: I am using a .cmd file.
source
share