Export registry key value to text or csv

Hello

I'm trying to find a vbscript that will do the following:

1. Look for the key "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General"
2. Get the value for "UserTemplates" in this key
3. Output the information into a text file with the %computername% and if possible the %username% of the user that's logged into the system, to make easier for finding the user.

The idea behind this is to gather all the paths from a lot of computers and see which ones are using a network path for the User Templates path, as opposed to a path on their local C-Drive  (where it should be).

Targets are Windows XP users. Systems are on a domain. The script output results can be saved to a shared \\server path.
garryshapeAsked:
Who is Participating?
 
johnb6767Commented:
Typo on last line of code.... (surprising huh?)

echo>>\\server\share\OfficeGeneral.txt

should be

echo.>>\\server\share\OfficeGeneral.txt

Adds a space between sections... Not needed, just helps pretty the output....
0
 
gintu01Commented:
Select the key then file > Export.  it allows you to select .txt files when saving.
0
 
johnb6767Commented:
This is simpole batch, not vbs... Thought I would offer it anyway....  :)
@echo off
echo %computername%/%username% >>\\server\share\OfficeGeneral.txt
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>\\server\share\OfficeGeneral.txt
reg query "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General" /v "UserTemplates">>\\server\share\OfficeGeneral.txt
echo>>\\server\share\OfficeGeneral.txt

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
WindowsITAdminCommented:
Here http://gallery.technet.microsoft.com/ScriptCenter/en-us/801ea35e-75d0-4c9f-abb7-47f65a89b478 is a script to read the registry key, then put it into a .txt file.
0
 
garryshapeAuthor Commented:
Thanks, that works great. The batch works right off the bat. The VBScript helps but I'll need to modify with some research.

Thanks again.
0
 
mcsweenSr. Network AdministratorCommented:
Here is the VBScript version you asked for...

Option Explicit
On Error Resume Next

Dim wShell, fso, adInfo, strTemplatesVal, strServerShare, strOutFile

strServerShare = "\\SomeServer\SomeShare\"

Const reg1 = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General\UserTemplates"

Set wShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set adInfo = CreateObject("ADSystemInfo")

strTemplatesVal = wShell.RegRead(reg1)

Set strOutFile = fso.CreateTextFile(strServerShare & adInfo.ComputerName & "-" & adInfo.UserName & ".txt",true)

If strTemplatesVal <> Null Then
 strOutFile.Write strTemplatesVal
Else
 strOutFile.Write "Key does not Exist " & reg1
End If

Open in new window

0
 
WindowsITAdminCommented:
If you need help with the vbs script i'll be pleased of helping you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.