Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Export 4 Registry keys to a text file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,41899
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Export 4 Registry keys to a text file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Export 4 Registry keys to a text file - 1/11/2007 2:17:02 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Can anyone help I need to export 4 Registry keys to a text file and name the text file with the computer name.  Here are the keys

sRegPath1 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
sRegPath2 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce"
sRegPath3 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx"
sRegPath4 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices"
 
 
Post #: 1
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 2:32:37 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
What do you mean export? Retrieve the values in these key paths?  Do a search for StdRegProv.  There's a thread on this forum where they show several examples of using it.
http://www.visualbasicscript.com/m_31698/tm.htm

Do a search of FileSystemObject for the writing to text part.

< Message edited by dm_4ever -- 1/11/2007 2:33:44 AM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aburt)
 
 
Post #: 2
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 2:34:23 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
yes retrieve the values and place in a text file with the name of the computer.

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 2:56:47 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
so far here is what I have come up with but I since I am new to scripting I am not sure how to add the other Keys and output to text any help would be appreciated greatly


Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Run"
strValueName = "Windows Logon Service"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
WScript.Echo "SYSTEM\CurrentControlSet\Control\" _
& "Run" _
& " = " & strValue

(in reply to aburt)
 
 
Post #: 4
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 3:22:51 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Are you looking for specific value names under those keys or all of them and their values?  If you're going for all of them, you can use the EnumValues method to get an array of all the value names and then you can use the GetStringValue method to read the value.  To add the other keys you may think about putting them into an array.  There are plenty of examples of writing to a text file in this forum; you can also look here: http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true .  Try to get your data first and then worry about exporting it to a text file.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aburt)
 
 
Post #: 5
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 3:31:18 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Ok I will check out that post for the text file.  Yes I am looking specifically for the Windows logon Service.  I do not know how write the script to get the other values.  Since you suggested getting the data first.  Can you help me get the other values

(in reply to dm_4ever)
 
 
Post #: 6
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 4:17:23 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Can anyone help me get the windows logon service value from the following registry keys and output to text file named with a computer name. 

sRegPath1 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
sRegPath2 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce"
sRegPath3 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx"
sRegPath4 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices"






function ResizeTextArea(){
// return;
var TextArea = document.getElementById("body1");
var sX = document.body.clientWidth;
var sY = document.body.clientHeight;
var sppp = 350;
if (TextArea){
TextArea.style.width = (sX-200>=450)? (sX-200) +'px' : '450px';
if (sY=300)? '270px': (sY-sppp



Heres what I have so far

Dim oFilesys, oFiletxt, sFilename, sPath
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oFilesys = CreateObject("Scripting.FileSystemObject")
Set oFiletxt = oFilesys.CreateTextFile("c:\test.txt, True)
sPath = oFilesys.GetAbsolutePathName("c:\inventory.txt")
Set StdOut = WScript.StdOut
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Run"
strValueName = "Windows Logon Service"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
oFiletxt.WriteLine("SYSTEM\CurrentControlSet\Control\Run = "& strValue)
oFiletxt.Close'

(in reply to aburt)
 
 
Post #: 7
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 4:29:31 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Last Post Had Errors sorry

Can anyone help me get the windows logon service value from the following registry keys and output to text file named with the computer name. 

sRegPath1 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
sRegPath2 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce"
sRegPath3 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx"
sRegPath4 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices"

Heres what I have so far

Dim oFilesys, oFiletxt, sFilename, sPath
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oFilesys = CreateObject("Scripting.FileSystemObject")
Set oFiletxt = oFilesys.CreateTextFile("c:\test.txt, True)
sPath = oFilesys.GetAbsolutePathName("c:\inventory.txt")
Set StdOut = WScript.StdOut
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Run"
strValueName = "Windows Logon Service"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
oFiletxt.WriteLine("SYSTEM\CurrentControlSet\Control\Run = "& strValue)
oFiletxt.Close'

(in reply to aburt)
 
 
Post #: 8
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 4:44:07 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You can try something like this:


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aburt)
 
 
Post #: 9
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 5:06:45 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Oh thanks heaven someone heard my cry for help

Thanks this kinda works.  The output is

Computer Name: Machine Name
SYSTEM\CurrentControlSet\Control\Run =
SYSTEM\CurrentControlSet\Control\Run =
SYSTEM\CurrentControlSet\Control\Run =
SYSTEM\CurrentControlSet\Control\Run =

Can you help me get the output too

Computer Name: Machine Name
SYSTEM\CurrentControlSet\Control\Run =
SYSTEM\CurrentControlSet\Control\RunOnce =
SYSTEM\CurrentControlSet\Control\RunEx=
SYSTEM\CurrentControlSet\Control\RunServices =

(in reply to dm_4ever)
 
 
Post #: 10
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 5:09:14 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Option Explicit
'On Error Resume Next
Dim oReg, strComputer, strValueName, oFilesys, oFiletxt
Dim sFilename, sPath, oNetwork, arrKeyPaths(3), i, strValue
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForWriting = 2
strComputer = "."
arrKeyPaths(0) = "Software\Microsoft\Windows\CurrentVersion\Run"
arrKeyPaths(1) = "Software\Microsoft\Windows\CurrentVersion\RunOnce"
arrKeyPaths(2) = "Software\Microsoft\Windows\CurrentVersion\RunOnceEx"
arrKeyPaths(3) = "Software\Microsoft\Windows\CurrentVersion\RunServices"
strValueName = "Windows Logon Service"  'looking for this key name in the path's listed above
Set oNetwork = CreateObject("WScript.Network")
Set oFilesys = CreateObject("Scripting.FileSystemObject")
Set oFiletxt = oFilesys.OpenTextFile("c:\test.txt", ForWriting, True)
Set oReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
oFiletxt.WriteLine "Computer Name: " & oNetwork.ComputerName
For i = 0 To UBound(arrKeyPaths)
   oReg.GetStringValue HKEY_LOCAL_MACHINE, arrKeyPaths(i), strValueName, strValue
   oFiletxt.WriteLine(arrKeyPaths(i) & " = "& strValue)
Next
oFiletxt.Close

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aburt)
 
 
Post #: 11
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 5:26:56 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Hey thanks works like a charm

One question if I want all the text files share on the network if I change the

Set oFiletxt = oFilesys.OpenTextFile("c:\" & oNetwork.ComputerName & ".txt", ForWriting, True)

to

Set oFiletxt = oFilesys.OpenTextFile("\\share\dir" & oNetwork.ComputerName & ".txt", ForWriting, True)

I dont get any output.  Am I doing something wrong

(in reply to ebgreen)
 
 
Post #: 12
 
 RE: Export 4 Registry keys to a text file - 1/11/2007 6:58:30 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Set oFiletxt = oFilesys.OpenTextFile("\\share\dir\" & oNetwork.ComputerName & ".txt", ForWriting, True)

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aburt)
 
 
Post #: 13
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Export 4 Registry keys to a text file Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts