Garry Shape
asked on
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\Softwar e\Microsof t\Office\1 2.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.
I'm trying to find a vbscript that will do the following:
1. Look for the key "HKEY_CURRENT_USER\Softwar
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.
Select the key then file > Export. it allows you to select .txt files when saving.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
Thanks again.
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
If you need help with the vbs script i'll be pleased of helping you.