Batch script and two .reg files.

July 16, 2009 at 20:38:59
Specs: Windows XP/Vista
Hello!

I'm trying to create a batch file that will parse through a "foo.reg" file to create a new "bar.reg" file.

Here's an example of a "foo.reg" file:

---
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\AVG8_TRAY]
"item"="AVG8_TRAY"
"command"="C:\\PROGRA~1\\AVG\\AVG8\\avgtray.exe"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\LightScribe Control Panel]
"item"="LightScribe Control Panel"
"command"="C:\\Program Files\\Common Files\\LightScribe\\LightScribeControlPanel.exe -hidden"
"hkey"="HKEY_CURRENT_USER"
"key"="Run"
---

...and here's how I would like the output "bar.reg" file to look:

---
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"AVG8_TRAY"="C:\\PROGRA~1\\AVG\\AVG8\\avgtray.exe"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"LightScribe Control Panel"="C:\\Program Files\\Common Files\\LightScribe\\LightScribeControlPanel.exe -hidden"
---

I have a VERY basic understanding, but just can't translate it into a batch file.

- ignore what is in the brackets [] including the brackets themselves

- for every instance of "hkey"="HKLM", output [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

- for every instance of "hkey"="HKEY_CURRENT_USER", output [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]

- on the next line, output the string that after "item"= (with the quotes) and make it equal to the string that is after "command"= (with the quotes)

Any input would be greatly appreciated!


See More: Batch script and two .reg files.

Report •


#1
July 17, 2009 at 05:58:12
hmm...

Seems like the "item"= bit is BEFORE the "hkey"= ; isn't it?


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
July 17, 2009 at 07:10:40
Yes. I see that as being a bit of a problem since I can only see
the batch file iterating through the .reg file one line at a time from
the beginning of the file to the end of the file.

Would a VBScript be more suitable?


Report •

#3
July 17, 2009 at 11:49:38
Is the file strictly as posted, ie a title and blocks of 5 lines each separated by blanks?


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions

#4
July 17, 2009 at 14:37:36
I wish I could attach the file. I've copy and pasted it without any formatting below, but there are line breaks where there shouldn't be.


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\Adobe Reader Speed Launcher]
"item"="Adobe Reader Speed Launcher"
"command"="\"C:\\Program Files\\Adobe\\Reader 
8.0\\Reader\\Reader_sl.exe\""
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\AdobeUpdater]
"item"="AdobeUpdater"
"command"="\"C:\\Program Files\\Common 
Files\\Adobe\\Updater5\\AdobeUpdater.exe\""
"hkey"="HKEY_CURRENT_USER"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\amBX Daemon]
"item"="amBX Daemon"
"command"="\"C:\\Program Files\\amBX\\Control 
Panel\\amBXDaemon.exe\""
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\amBX System Tray Application]
"item"="amBX System Tray Application"
"command"="C:\\Program Files\\amBX\\Gaming 
FXGen\\win32\\amBXFxGen.exe"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\AVG8_TRAY]
"item"="AVG8_TRAY"
"command"="C:\\PROGRA~1\\AVG\\AVG8\\avgtray.exe"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\EKIJ5000StatusMonitor]
"item"="EKIJ5000StatusMonitor"
"command"="C:\\WINDOWS\\System32\\spool\\DRIVERS\\
W32X86\\3\\EKIJ5000MUI.exe"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\EVEMon]
"item"="EVEMon"
"command"="\"C:\\Program Files\\EVEMon\\EVEMon.exe\" -
startMinimized"
"hkey"="HKEY_CURRENT_USER"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\Launch LCDMon]
"item"="Launch LCDMon"
"command"="\"C:\\Program Files\\Common 
Files\\Logitech\\LCD Manager\\lcdmon.exe\""
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\Launch LGDCore]
"item"="Launch LGDCore"
"command"="\"C:\\Program Files\\Common 
Files\\Logitech\\G-series Software\\LGDCore.exe\" 
/SHOWHIDE"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\LightScribe Control Panel]
"item"="LightScribe Control Panel"
"command"="C:\\Program Files\\Common 
Files\\LightScribe\\LightScribeControlPanel.exe -hidden"
"hkey"="HKEY_CURRENT_USER"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\Logitech Hardware Abstraction 
Layer]
"item"="Logitech Hardware Abstraction Layer"
"command"="KHALMNPR.EXE"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\NvCplDaemon]
"item"="NvCplDaemon"
"command"="RUNDLL32.EXE 
C:\\WINDOWS\\system32\\NvCpl.dll,NvStartup"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\NvMediaCenter]
"item"="NvMediaCenter"
"command"="RUNDLL32.EXE 
C:\\WINDOWS\\system32\\NvMcTray.dll,NvTaskbarInit"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\NVMixerTray]
"item"="NVMixerTray"
"command"="\"C:\\Program Files\\NVIDIA 
Corporation\\NvMixer\\NVMixerTray.exe\""
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\SmartGuardian]
"item"="SmartGuardian"
"command"="C:\\Program Files\\ITE\\Smart 
Guardian\\ITESmart.exe"
"hkey"="HKLM"
"key"="Run"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared 
Tools\MSConfig\startupreg\SoundMan]
"item"="SoundMan"
"command"="SOUNDMAN.EXE"
"hkey"="HKLM"
"key"="Run"

Basically:

Line 1[...]
Line 2"item"="..."
Line 2"command"="..."
Line 3"hkey"="..."
Line 4"key"="..."

Hope this helps!


Report •

#5
July 17, 2009 at 15:56:05
Best bet is to ZIP it up and use:


www.sendthisfile.com


=====================================
If at first you don't succeed, you're about average.

M2


Report •


Ask Question