ajuda do script em lote, localizar, substituir chaves do registro

1

Estou tentando descobrir por que meu comando reg import não está funcionando no script abaixo. Quando eu executo o reg import file.reg do DOS ele funciona bem, mas quando incluído no script abaixo ele não faz nada e não consigo encontrar o porquê. Eu posso ver a exportação concluída corretamente e o formato parece ok para mim. Quando eu uso o comando reg import no mesmo arquivo exportado, ele funciona bem. Abaixo está o código.

@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
REM  This script updates the Windows Registry for the 

REM update Admin Nodes
set service1Key=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\MyService1\Parameters
set service2Key=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\MyService2\Parameters

echo updating [%service1Key%]
call :updateRegKeys %service1Key%
echo updating [%service2Key%]
call :updateRegKeys %service2Key%

SET count=3
set looper=1

FOR /L %%A IN (1,1,%count%) DO (call :updateAllServers %%A)
GOTO:EOF

:updateAllServers
SET domainKey=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\MyDomain%looper%\Parameters
SET otherDomainKey=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\MyOtherDomain%looper%\Parameters
echo [%domainKey%]
echo [%otherDomainKey%]
echo .
call :updateRegKeys %domainKey%
call :updateRegKeys %otherDomainKey%
set /a looper+=1
goto:eof

:updateRegKeys
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
set "registrykey=%1"
set findv="-Xms512m"
set replacev="-Xms512m something that is long"
echo "Updating registry values, please wait..."
REG EXPORT "%registrykey%" origReg.txt
call :findReplace %findv% %replacev% origReg.txt > newkeys.reg
reg import newkeys.reg
del /q newkeys.reg origReg.txt

:findReplace
REM finds and replaces a string 
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
set "line=%%B"
if defined line (
    call set "line=echo.%%line:%~1=%~2%%"
    for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
) ELSE echo.
)
goto:eof
    
por powerhouse 23.01.2013 / 09:21

1 resposta

0

Adicionando

ping 1.1.1.1 -n 5 > null

Consegui pausar um pouco enquanto o arquivo estava sendo gravado no disco ... isso resolveu meu problema

    
por 01.02.2013 / 03:40