Script that pulls data from text file and creates registry keys (Full Version)

All Forums >> [Scripting Technologies] >> VB Script



Message


jscott607 -> Script that pulls data from text file and creates registry keys (6/26/2008 1:59:03 PM)

I am trying to pull information from a text file and then create registry keys with the information. So far, I am not having much luck.

The text file has information like what I have below. I am trying to get the script to read the text file and look for the share information. Once it finds that information, it creates one registry entry for Share 1 with \\uschmfp1\test$ as the value and another entry for Share 2 with \\uschmfp1\user1$  as the value. These shares will not be static and would vary for each system.

Binary file information:
File.......: C:\WINDOWS\system32\CSCDLL.DLL
Size.......: 101,888 bytes
Created....: 8/4/2004 8:00:00 AM
File.......: C:\WINDOWS\system32\CSCUI.DLL
Size.......: 326,656 bytes
Created....: 8/4/2004 8:00:00 AM
File.......: C:\WINDOWS\system32\drivers\MRXSMB.SYS
Size.......: 453,120 bytes
Created....: 8/4/2004 8:00:00 AM
File.......: C:\WINDOWS\system32\drivers\RDBSS.SYS
Size.......: 174,592 bytes
Created....: 8/4/2004 8:00:00 AM
Cache information:
CSC enabled..............: Yes
Volume...................: C:\
Bytes on volume..........: 80,015,519,744
Max auto-cache bytes.....: 2,147,483,647 (2.68% of volume)
Current auto-cache bytes.: 12,288 (0.00% of max)
Files in cache...........: 38
Directories in cache.....: 47
Cache encrypted?.........: No
Share                         Status           Files      Dirs    Pinned  Modified    Sparse      USER     GUEST     OTHER  Offline?  OpenFiles?
\\uschmfp1\test$          0x00330000          27        36        63         0         0         4         0        27        No          No
\\uschmfp1\user1$          0x00030A00           3         9         7         0         0         3         0         0        No          No
SUMMARY                                           30        45        70         0         0         7         0        27         0           0


My script is below. At this point, I can only get it to create one registry entry and it uses the last share as the value. Does anyone have advice? Any assistance would be greatly appreciated.

Const ForReading = 1

strComputer = "."
strFile = "C:\windows\logs\offline.txt"
intCount = 0
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Offline_Share"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(strFile, ForReading)

Do Until objFile.AtEndOfStream
strLine = objFile.Readline

If strLine <> "" Then
 arrLine = Split(strLine, " ")
 If arrLine(0) = "Share" Then
  intCount = intCount + 1
 ElseIf arrLine(0) = "SUMMARY" Then
  intCount = intCount + 1
 ElseIf intCount = 1 Then
  strShare = arrLine(0)
  WScript.Echo strShare
   
  strKeyPath = "SOFTWARE\Offline_Share"
  strShare1 = "Share 1"
  strShare1Value = strShare
     oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strShare1,strShare1Value
  
 End If
End If
Loop

objFile.Close




jscott607 -> RE: Script that pulls data from text file and creates registry keys (6/27/2008 8:34:52 AM)

I no longer need assistance. Thanks




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.296875