China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 20:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to implement this function with batch processing View 2,338 Replies 17
Original Poster Posted 2006-07-06 11:19 ·  新加坡
中级用户
★★
Credits 249
Posts 64
Joined 2005-06-03 00:00
21-year member
UID 39315
Gender Male
Status Offline
I'm using a genuine version of Rising Antivirus. I want to create an IMG file for Rising Antivirus. The key is to extract the virus database files from RISING\RAV. The virus database files are: 8 def files (VirBoot.def, VIRCOM.def, VirInfo.def, VirMacr.def, VirMZ.def, VirNorm.def, VirPe.def, VirSct.def), 15 dll files (engine.dll, extFile.dll, ExtMail.dll, ExtOLE.dll, libload.dll, RsStore.dll, ScanEX.dll, ScanExec.dll, ScanMac.dll, ScanSct.dll, slang936.dll, UnExe.dll, vdp.dll, VirusLib.dll, Zip.DLL), and one virusdb.cfg file. Also, I need to create a Version.inf file according to the content of the virusdb.cfg file (the date and version number in the content will be different each time it's updated). Here I list the content of virusdb.cfg after the update on June 26, 2006:


FILECOUNT=13
ENGINEVER=17.00.00.36
VIRDEFVER=18.32.42.00
VIRDEFUPDATEDATE=2006-06-23


COM=VirCom.def
MZ=VirMZ.def
PE=VirPe.def
MACRO=VirMacr.def
SCRIPT=VirSct.def
NORMAL=VirNorm.def
BOOT=VirBoot.def
ELF=VirElf.def
INFO=VirInfo.def
MEM=SysMem.def
PTLIB=Posttrt.def
WLLIST=wllib.def
NVLIST=nvlib.def


INFO=VirusLib.dll
MEM=VirusLib.dll
PTLIB=VirusLib.dll
WLLIST=VirusLib.dll
NVLIST=VirusLib.dll

Also listed is the content of VERSION.INF created manually according to VIRUSDB.CFG:


VersionNo=18.32.42
UpdateDate=2006-06-23

The VERSION.INF file is used to display the version number. It's very cumbersome to create VERSION.INF manually each time. I want to use a batch process to achieve this. Could some kind - hearted person help?

The following is the batch process I put in the RISING directory to extract virus files. I just need to add the function to create the VERSION.INF file later. The created VERSION.INF should also be in the 001 directory.

MD 001
COPY /Y .\Rav\VirBoot.def .\001
COPY /Y .\Rav\VirCom.def .\001
COPY /Y .\Rav\VirInfo.def .\001
COPY /Y .\Rav\VirMacr.def .\001
COPY /Y .\Rav\VirMZ.def .\001
COPY /Y .\Rav\VirPe.def .\001
COPY /Y .\Rav\VirSct.def .\001
COPY /Y .\Rav\ENGINE.DLL .\001
COPY /Y .\Rav\EXTFILE.DLL .\001
COPY /Y .\Rav\EXTMAIL.DLL .\001
COPY /Y .\Rav\EXTOLE.DLL .\001
COPY /Y .\Rav\LIBLOAD.DLL .\001
COPY /Y .\Rav\RsStore.dll .\001
COPY /Y .\Rav\ScanEx.dll .\001
COPY /Y .\Rav\SCANEXEC.DLL .\001
COPY /Y .\Rav\SCANMAC.DLL .\001
COPY /Y .\Rav\SCANSCT.DLL .\001
REM COPY /Y .\Rav\sLang936.dll .\001
COPY /Y .\Rav\Unexe.dll .\001
COPY /Y .\Rav\VDP.DLL .\001
COPY /Y .\Rav\VirusLib.dll .\001
COPY /Y .\Rav\ZIP.DLL .\001
COPY /Y .\Rav\VirNorm.def .\001
COPY /Y .\Rav\VIRUSDB.CFG .\001

[ Last edited by tclshx on 2006-7-6 at 11:39 ]
Floor 2 Posted 2006-07-06 12:49 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
@echo off
setlocal
for /f "tokens=2 delims==" %%a in ('findstr /c:"VIRDEFVER" /c:"VIRDEFUPDATEDATE" virusdb.cfg') do (
if defined a (set b=%%a) else set a=%%a
)
echo [Version]>.\001\VERSION.INF
echo VersionNo=%a:~0,-3%>>.\001\VERSION.INF
echo UpdateDate=%b%>>.\001\VERSION.INF



@echo off
setlocal
for /f "tokens=2 delims==" %%a in ('findstr "VIRDEFVER VIRDEFUPDATEDATE" virusdb.cfg') do (
if defined a (set b=%%a) else set a=%%a
)
echo [Version]>.\001\VERSION.INF
echo VersionNo=%a:~0,-3%>>.\001\VERSION.INF
echo UpdateDate=%b%>>.\001\VERSION.INF


Both should work, just changed the search...
Floor 3 Posted 2006-07-06 13:35 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
@echo off
set Version=VIRDEFVER
find /i virusdb.cfg "%Version%"
if not errorlevel 1 set Version=VersionNo
for /F "tokens=1 delims=VIRDEFVER " %%A in ('find /i .\Rav\virusdb.cfg "VIRDEFVER"') do set No=%%A
for /F "tokens=1 delims=VIRDEFUPDATEDATE " %%B in ('find /i .\Rav\virusdb.cfg "VIRDEFUPDATEDATE"') do set DATENO=%%B
echo >.\001\VERSION.INF
echo %Version%%NO%>>.\001\VERSION.INF
echo UpdateDate%DATENO%>>.\001\VERSION.INF

[ Last edited by fastslz on 2006-7-6 at 13:53 ]
Floor 4 Posted 2006-07-06 13:49 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Hehe... Compared with bagpipe, my method is relatively clumsy. But I have tested it. Please add the path, building block: When the full path of this.\Rav\ virtual path is C:\Program Files\Rav, there will be an error prompt.
Floor 5 Posted 2006-07-06 13:56 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
What matters is the method, not being smart or not. Everyone has different ideas, but it's okay as long as the results are the same. Everyone is here for learning, and everyone starts from being inexperienced, so it's all the same
Floor 6 Posted 2006-07-06 15:39 ·  新加坡
中级用户
★★
Credits 249
Posts 64
Joined 2005-06-03 00:00
21-year member
UID 39315
Gender Male
Status Offline
Originally posted by bagpipe at 2006-7-6 12:49 PM:
@echo off
setlocal
for /f "tokens=2 delims==" %%a in ('findstr /c:"VIRDEFVER" /c:"VIRDEFUPDATEDATE" virusdb.cfg') do (
if defined a (set b=%%a) else set a=%%a
)
e ...


The result of the second floor is:
The content of VERSION.INF is

VersionNo=~0,-3
UpdateDate=

The result of the third floor is:
The content of VERSION.INF is

VIRDEFVER=18.34.31.00
UpdateDate=2006-07-06

The correct one should be
The content of VERSION.INF is

VIRDEFVER=18.34.31
UpdateDate=2006-07-06
Otherwise, when running the IMG of Rising DOS antivirus, the version number cannot be displayed correctly (version: 18.34.31)
Floor 7 Posted 2006-07-06 16:16 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
You first take a look at where your problem is, don't just focus on the result. Why didn't I have the situation you mentioned when I tested it on my local machine?
Floor 8 Posted 2006-07-06 16:25 ·  新加坡
中级用户
★★
Credits 249
Posts 64
Joined 2005-06-03 00:00
21-year member
UID 39315
Gender Male
Status Offline
Originally posted by bagpipe at 2006-7-6 04:16 PM:
You first take a look at where your problem is, don't just focus on the result. I tested it on my local machine and didn't encounter the situation you mentioned.

My Rising antivirus is installed on drive D. I placed this batch processing in the RISING directory, and the RAV directory is also in this directory.
My entire batch processing is as follows:
@echo off
MD 001
COPY /Y .\Rav\VirBoot.def .\001
COPY /Y .\Rav\VirCom.def .\001
COPY /Y .\Rav\VirInfo.def .\001
COPY /Y .\Rav\VirMacr.def .\001
COPY /Y .\Rav\VirMZ.def .\001
COPY /Y .\Rav\VirPe.def .\001
COPY /Y .\Rav\VirSct.def .\001
COPY /Y .\Rav\ENGINE.DLL .\001
COPY /Y .\Rav\EXTFILE.DLL .\001
COPY /Y .\Rav\EXTMAIL.DLL .\001
COPY /Y .\Rav\EXTOLE.DLL .\001
COPY /Y .\Rav\LIBLOAD.DLL .\001
COPY /Y .\Rav\RsStore.dll .\001
COPY /Y .\Rav\ScanEx.dll .\001
COPY /Y .\Rav\SCANEXEC.DLL .\001
COPY /Y .\Rav\SCANMAC.DLL .\001
COPY /Y .\Rav\SCANSCT.DLL .\001
REM COPY /Y .\Rav\sLang936.dll .\001
COPY /Y .\Rav\Unexe.dll .\001
COPY /Y .\Rav\VDP.DLL .\001
COPY /Y .\Rav\VirusLib.dll .\001
COPY /Y .\Rav\ZIP.DLL .\001
COPY /Y .\Rav\VirNorm.def .\001
COPY /Y .\Rav\VIRUSDB.CFG .\001

setlocal
for /f "tokens=2 delims==" %%a in ('findstr /C:"VIRDEFVER" /C:"VIRDEFUPDATEDATE" virusdb.cfg') do (if defined a (set b=%%a) else set a=%%a)
echo >.\001\VERSION.INF
echo VersionNo=%a:~0,-3%>>.\001\VERSION.INF
echo UpdateDate=%b%>>.\001\VERSION.IN

I tried both of your batch processings, and the content of VERSION.INF is the same:

VersionNo=~0,-3
UpdateDate=
Floor 9 Posted 2006-07-06 17:21 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
I want to ask where the location of your "virusdb.cfg" file is?
Floor 10 Posted 2006-07-06 17:24 ·  新加坡
中级用户
★★
Credits 249
Posts 64
Joined 2005-06-03 00:00
21-year member
UID 39315
Gender Male
Status Offline
Originally posted by bagpipe at 2006-7-6 05:21 PM:
I want to ask where the location of your "virusdb.cfg" file is?


The virusdb.cfg file is copied from the RAV directory to the 001 directory by the batch processing.
Floor 11 Posted 2006-07-06 17:28 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
Then he just can't find that file. Try 'findstr /C:"VIRDEFVER" /C:"VIRDEFUPDATEDATE" .001\virusdb.cfg' again. By the way, what system are you using?
Floor 12 Posted 2006-07-06 17:29 ·  新加坡
中级用户
★★
Credits 249
Posts 64
Joined 2005-06-03 00:00
21-year member
UID 39315
Gender Male
Status Offline
Originally posted by bagpipe at 2006-7-6 05:28 PM:
Then he just can't find that file
'Try 'findstr /C:"VIRDEFVER" /C:"VIRDEFUPDATEDATE" .001\virusdb.cfg' again. By the way, what system are you using?


XP_sp2
Floor 13 Posted 2006-07-06 17:31 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
You can try modifying it. This is the reason for not finding that CFG file
Floor 14 Posted 2006-07-06 17:36 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
I just made a mistake with the path earlier. It should be .\001\virusdb.cfg like this.
Floor 15 Posted 2006-07-06 17:37 ·  新加坡
中级用户
★★
Credits 249
Posts 64
Joined 2005-06-03 00:00
21-year member
UID 39315
Gender Male
Status Offline
Originally posted by bagpipe at 2006-7-6 05:31 PM:
Try modifying it. This is the reason for not finding that CFG file



setlocal
for /f "tokens=2 delims==" %%a in ('findstr /C:"VIRDEFVER" /C:"VIRDEFUPDATEDATE" virusdb.cfg') do (if defined a (set b=%%a) else set a=%%a)
echo >.\001\VERSION.INF
echo VersionNo=%a:~0,-3%>>.\001\VERSION.INF
echo UpdateDate=%b%>>.\001\VERSION.IN
Changed to
setlocal
for /f "tokens=2 delims==" %%a in ('findstr /C:"VIRDEFVER" /C:"VIRDEFUPDATEDATE" .001\virusdb.cfg') do (if defined a (set b=%%a) else set a=%%a)
echo >.\001\VERSION.INF
echo VersionNo=%a:~0,-3%>>.\001\VERSION.INF
echo UpdateDate=%b%>>.\001\VERSION.INF

The result is still the same as before modification.

The one on the third floor just adds ".00" after the version number in the result. The improvement he made might work, but I don't know how.
Forum Jump: