Hi everyone I am lost...
I have admin rights.
I want to modify registry key in HKEY_CURRENT_USER\Software.... on remote PC where another user is logged.
I don't want to use PowerShell because we don't have remote registry enabled.
I am stuck with cmd
Therefore I use PSexec.
If I want to change something in global HKLM its pretty easy
psexec \\COMPUTERNAME reg add HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\...... /t REG_DWORD
since I call the psexec as admin it allows me to change anything in HKLM on the remote machine
but when I need to change something in HKCU I need the SID of the user to plug it into HKEY_USERS\SID\SOFTWARE\ and that's where I hit a wall...
I tried something like this (it didn't work, the syntax is probably all wrong)
psexec \\COMPUTERNAME for /F "skip=1 tokens=1" %%i in ('query user') do set varusername=%%i
this was supposed to get remote logged users name into variable 'varusername' to later use it to get SID
something like this (again the syntax is probably wrong):
psexec \\COMPUTERNAME wmic useraccount where name='%varusername%' get sid
this completely blew up since wmic on the remote computer when executed as admin (via psexec) doesn't see the same users as query user...
here is the output of the respective commands
query user give me the logged user name 'johndoe'
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
johndoe console 1 Active none 9/10/2018 5:27
wmic useraccount get name, sid does not see the 'johndoe' at all
Name SID
DefaultAccount S-1-5-21-3285310242-2953612481-1302521585-503
defaultuser0 S-1-5-21-3285310242-2953612481-1302521585-1002
LocalAdmin S-1-5-21-3285310242-2953612481-1302521585-500
Guest S-1-5-21-3285310242-2953612481-1302521585-501
so as you can see I hit the wall
query user gives me logged user on remote PC "johndoe" but I have no way to get SID of "johndoe" using wmic useraccount to plug it into:
psexec \\COMPUTERNAME reg add HKEY_USERS\SID\SOFTWARE\Microsoft\...... /t REG_DWORD
any ideas how to get around this?
I just need to edit HKCU on remote PC for a currently logged user without using PowerShell