Jump to content

Scripting Help


Recommended Posts

I am looking on advice to writing a script in preferably Batch/CMD or VBS with PERL being an option. What I am trying to accomplish is either directly writing information obtained from a command line tool into some strings / keys into the registry.

We are currently running CA Threat Manager 8.1 (AV and PestPatrol). From CA there is a command line tool called 'CompVer' that will output all the particular information related to signature version and AV base version. I either need to run this CompVer utility in a script and directly write 3 of the results into a registry key or write them out to a text file and import that into the registry.

Here is the work I've done so far:

>>>Run Compver and output to a text file<<<

REM Run CompVer and output to a textfile
@ECHO OFF
compver | Find "eTrust Antivirus Base" >> C:\ITM.txt && compver | Find "eTrust PestPatrol Signatures" >> C:\ITM.txt && compver | Find "eTrust Vet Engine" >> C:\ITM.txt
EXIT

>>>Write entries to the registry<<<

@ECHO OFF
REM Write to REG Key
REG ADD HKLM\SOFTWARE\ComputerAssociates\eTrustITM\Status
REG ADD HKLM\SOFTWARE\ComputerAssociates\eTrustITM\Status /v "eTrust AntiVirus Base" /t REG_MULTI_SZ

I am looking for some way, hopefully in the same script to write the entries inside of C:\ITM.txt into the registry. I am assuming that this would use the FOR command however I have little experience with this command when writing batch. Like I said, VBS is an option but I haven't explored it yet as I am looking for something quick.

Link to comment
Share on other sites


Here are my findings, his so far is working great. Alot of work for such a small script but it does its job. Revision 2 I guess would be a way to write directly to the registry without the need for text files. Not a bad attempt for never having used the FOR command.

@ECHO OFF
cd \
SET VAR=eTrust Antivirus Base
SET VAR1=eTrust PestPatrol Signatures
SET VAR2=eTrust Vet Engine
CompVer | Find "%VAR%" >> C:\ITM.txt
CompVer | Find "%VAR1%" >> C:\ITM2.txt
CompVer | Find "%VAR2%" >> C:\ITM3.txt
REG ADD HKLM\SOFTWARE\ComputerAssociates\eTrustITM\Status
FOR /F "tokens=4 delims=, " %%i in (C:\ITM.txt) DO @REG ADD HKLM\SOFTWARE\ComputerAssociates\eTrustITM\Status /v "%VAR%" /d %%i
FOR /F "tokens=4 delims=, " %%j in (C:\ITM2.txt) DO @REG ADD HKLM\SOFTWARE\ComputerAssociates\eTrustITM\Status /v "%VAR1%" /d %%j
FOR /F "tokens=4 delims=, " %%k in (C:\ITM3.txt) DO @REG ADD HKLM\SOFTWARE\ComputerAssociates\eTrustITM\Status /v "%VAR2%" /d %%k
DEL "C:\ITM.txt" && DEL "C:\ITM2.txt" && DEL "C:\ITM3.txt"
EXIT

Link to comment
Share on other sites

You shouldn't need the temporary .txt files. :unsure:

Does this output the wanted result?

SET VAR=eTrust Antivirus Base
FOR /F "tokens=4 delims=, " %%i in ('CompVer ^| Find "%VAR%"') DO ECHO @REG ADD HKLM\SOFTWARE\ComputerAssociates\eTrustITM\Status /v "%VAR%" /d %%i

jaclaz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...