How to use the path from reg query in another command

14 Views Asked by At

I'm attempting to use the following command in a logon script to copy the value of a key in the registry to another location. REG COPY "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\S-1-5-5-0-440072315" "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows" This command runs fine but the issue is that the value of S-1-5-5-0-440072315 changes with each session.

I can run a reg query command to find that path each time but I don't know how to use that result in the reg copy command to set the correct path. REG QUERY "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices returns HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\S-1-5-5-0-1549453136

I've attempted to use For /f commands to set the path as a variable but haven't been able to determine how, all the examples I've found are for setting the values in the keys e.g. Dwords and strings as variables, I've tried to modify them but without success.

0

There are 0 best solutions below