Add value of a variable in a record

Asked

Viewed 33 times

-2

I created a bat to add a file content to a record value, but I can’t get the contents of the play variable in the value.

This is my . BAT

@echo off
setlocal EnableDelayedExpansion
If exist "MD5arquivo.TXT" del MD5arquivo.TXT
set /a cont=0
for /f "delims= skip=4" %%a in (C:\commerce\MD5-PAF-ECF-LINX.TXT) do (
echo %%a>> MD5arquivo.TXT
set /p var=<MD5arquivo.TXT
set /a cont=!cont!+1
if "!cont!"=="2" goto novo
pause
)

:novo
reg add HKLM\Software\RegisteredApplications /v "MD5-PAF-ECF-LINX.TXT" /d %var%

when playing the contents of the variable %var% in the record is shown the error below

Erro

When using the echo command to display the contents of my variable, I realize that its content is what I need, as returned below

inserir a descrição da imagem aqui

How can I fix this?

1 answer

0

I’m sorry, but I think you’ve complicated your logic/code...

It would be nice to add the contents of your file MD5-PAF-ECF-LINX.TXT, just to get a better idea of what you seek to achieve with your bat..

Idependente of the layout/content of your file, try:

@echo off 

cd/d "%~dp0"
for /f usebackq^tokens^=*skip^=5 %%a in (`type "C:\commerce\MD5-PAF-ECF-LINX.TXT"`
    `)do reg add HKLM\Software\RegisteredApplications /v "MD5-PAF-ECF-LINX.TXT" /t REG_DWORD d "%%~a" /f & goto :novo

:novo
  • Remarks:

skip^=4 will skip 4 lines, remove counter and use Skip^=5 or 6 if applicable
if "String" == "String" use quotes and "==" is for character strings in your comparison
if Números equ 9999999 use equ/lss/leq/gtr/geq/etc... in numerical comparisons
%var% direct use of the variable in loop %%~a, do not need/delete/write/read/set any file
/t REG_DWORD ... /f consider informing the type of entry and suppressing confirmations

  • Thanks for the reply, the contents of my archive are this: ; Slavasoft Optimizing Checksum Utility - fsum 2.52.00337 <www.slavasoft.com> ; Generated on 06/22/21 at 16:49:36 d6bd331a7ae1570912bc45228580fc6f *EXECUTABLES-LINX.TXT This logic is assembled to take the data of the last line, which is the data I need to play in my record, this file is constantly modified, but the result always comes in the last line, so use that way. I’ll try using your method.

  • @Daniel Edit your question and add row by row to your file

  • If you have the file, pq do not use certuil.exe (already has Windows) and grab the hash direct. No additional text file...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.