store SID in a variable

Posted by user361191 on Stack Overflow See other posts from Stack Overflow or by user361191
Published on 2010-06-08T09:21:22Z Indexed on 2010/06/08 12:22 UTC
Read the original article Hit count: 365

Filed under:
|

Hi, I need a way to store the current user's SID in a variable, I tried a lot of variants of:

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 

None are working

wmic path win32_useraccount where name='%UserName%' get sid should be returning 3 lines, i need the second one stored in a variabel

Can someone fix my script?

edit btw; I am using a .cmd file

© Stack Overflow or respective owner

Related posts about batch

Related posts about cmd