Remotely export HKEY Current User

I am wondering if it is possible and how to run a script against a couple hundred computers to export the following key value to a text file:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General. In General there is a String Value "UserTemplates" and it's the data in there I need to extract.

I tried deploying a batch to do this using a service that can execute scripts via an end agent that runs on the system, however, I found that since it's running under a service account, it cannot pull date from the "HKEY_CURRENT_USER" key.

How is it possible to get the date under that key for the actual user that is logged on and using the computer?

If this isn't possible let me know of a product that exists that can run these types of reports.. we'll be set.

@echo off
echo %computername%/%username% >>\\server1\share\usertemplates.txt
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>\\server1\share\usertemplates.txt
reg query "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General" /v "UserTemplates">>\\server1\share\usertemplates.txt

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The easiest way to do this is with a logon script.  Configure your script to run under the group policy node User Configuration\Windows Settings\Scripts\Logon.  Make sure that users have Write permission to the log file.  The information will then be recorded as each user logs on.
garryshapeAuthor Commented:
ok thanks
A question on the logon script. How can I make it only run once? I'm concerned with the logon script running every time they login over a few days I'm trying to collect results, that it will duplicate. I just need it to run once per computer and be done
garryshapeAuthor Commented:
I suppose if I leave the logon script going, I can filter out the duplicates within Excel
You could do something like this, which uses the findstr command to check whether the username and computer combination appears in the log file.

@echo off
set log=\\server1\share\usertemplates.txt
findstr /i /c:"%computername%/%username%" "%log%" || (
 echo %computername%/%username% >>"%log%"
 echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>"%log%"
 reg query "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General" /v "UserTemplates">>"%log%"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garryshapeAuthor Commented:
Thanks, this will definitely work
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.