Page 1 of 1

batch file help to call current login profile ssid and reg add value in

Posted: 13 Mar 2020 12:34
by junqi89
hi i need help on this i am trying to call an user ssid and then add a registry value into the ssid registry... The problem i facing if i run the batch file as administrator from other user profile it will call the administrator ssid instead of the userprofile ssid.. how can i overcome this problem to call userprofile ssid when i run as administrator?

For /F "Skip=1 Delims=" %%A In (
'"WMIC UserAccount Where (Name='%UserName%') Get SID"') Do For %%B In (%%A
) Do Reg Add "HKU\%%B\Software\Microsoft\Office\16.0\Common\Identity" /V DisableADALatopWAMOverride /T Reg_DWord /D 1 /F>Nul

Thanks for the help.

Re: batch file help to call current login profile ssid and reg add value in

Posted: 22 Apr 2020 14:05
by scavenger
when you open a CMD prompt as ADMIN, please type 'whoami'
you will see that you are still the same user.
your user has admin rights that's not the same as loggin in as administrator user or runas another user.
please give more context as why your %username% variable would be different when you run the script as admin