Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
Vespian

Batch File That Checks The Registary

Recommended Posts

Hi, I am hoping someone can help. I am currently writing a batch file that checks for a version of software in the registry then if the right version checks the server entry in the registry. I've managed to get the version of software part working thanks to this topic http://www.msfn.org/board/topic/113643-batch-file-that-check-version-in-registry/ and Wise Owl's advice in it but have become stuck.
 
This is my script so far
 

Set "key=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1FDB8EC6-BAF1-42F9-8E09-4D9AB369F1B5}"Reg query %key% /v DisplayVersion|Find "4.8.0.887">Nul&&(Goto ServerCheck)"framepkg.exe" /Install=Agent /Silent:ServerCheckSet "key=HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent"Goto Stop)"framepkg.exe" /Install=Agent /Silent:StopPause

The output from Set "key=HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent" is below. The part I'm looking to check is the ePOServerList    REG_SZ and if CMCSU-EPO-01.cict.local is in the entry and if so go to Stop.
 

Agent    EnableVDIMode    REG_SZ    0    Installed Path    REG_SZ    C:\Program Files\McAfee\Common Framework    binsphash    REG_SZ    B7BB45E1B73318C7F725E0A385C1DCC9D215FFE4D9CD3FDBB502DFE3CDD12EDC    LoggedOnUser    REG_SZ    wg_tech    (Default)    REG_SZ    SMBiosUUID    REG_SZ    00BC3E8C-6FB7-E111-8025-B05963090386    AgentGUID    REG_SZ    {AFC66908-0D2D-452D-B08A-650A52F6CFC6}    AgentWakeUpPort    REG_SZ    8081    IPAddress    REG_SZ    192.168.16.99    SubnetAddress    REG_SZ    192.168.16.0    SubnetMask    REG_SZ    255.255.255.0    MacAddress    REG_SZ    e8e0b70cc45e    ComputerName    REG_SZ    Y0185APH    LastASCTime    REG_DWORD    0x55642428    IPHostName    REG_SZ    Y0185APH.CWN    PropsVersion    REG_SZ    20150526074336    SequenceNumber    REG_DWORD    0x2    ePOServerList    REG_SZ    CMCSU-EPO-01.cict.local|10.221.195.103|447;MDGH-EPO-AHN3.cict.local|10.221.195.102|447    LastPolicyUpdateTime    REG_DWORD    0x55642428    LastPropsVersion    REG_SZ    20150526074336    McTrayAllowUpdate    REG_SZ    0
Edited by Yzöwl
Added code boxes.

Share this post


Link to post
Share on other sites

Welcome Vespian,

Here is something that may help. It is just the part that you requested help with.

@echo offsetlocal enabledelayedexpansionrem Ensure regData is undefined now so it can be tested later if it has been defined.set "regData="rem Token 2 is %%A, which is expected to be REG_SZ. Used only to get to token *, which is %%B, which is all of the data value.for /f "tokens=2*" %%A in ( 'reg query "HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent" /v ePOServerList') do set "regData=%%~B"rem If regData is not defined, then seems no good continuing?if not defined regData goto :stoprem Show the value of regData. Use delayed expansion as you can expect pipe characters in the string.echo regData=!regData!rem If substitution fails, then equality is true.if "!regData:CMCSU-EPO-01.cict.local=!" == "!regData!" goto :stoprem You only want to install framepkg.exe once. Need a flag variable to decide this i.e. if not %installed% ..."framepkg.exe" /Install=Agent /Silent:stoppauseendlocalgoto :eof

As mentioned in a comment, you only want to install framepkg.exe once so create a variable to use as a flag. Once the script installs framepkg.exe, then set the flag variable to a value i.e. 1. The you can test the variable later for value of 1 and not install if true. Use an initial value i.e. 0.

 

Share this post


Link to post
Share on other sites

I have a couple of observations with your 'uninstall entry' check.

 

There is no need to check the DisplayVersion, merely the existence of the key; because {1FDB8EC6-BAF1-42F9-8E09-4D9AB369F1B5} is pertinent only to the DisplayVersion 4.8.0.887 (i.e. McAfee Agent 4.8 Patch 1).

 

However are you sure you're only wanting to check for that specific version?

 

what about McAfee Agent 4.8:

  • key {11FEE8E5-D9BD-4AC1-8074-5169069DF812}; DisplayVersion 4.8.0.641

and McAfee Agent 4.8 Patch 2?

  • key {EBF3D65F-011E-44D2-8F4F-C74B52682EDD}; DisplayVersion 4.8.0.1500

Also don't forget that persons using a 64bit OS will have that uninstall key in a different location

Share this post


Link to post
Share on other sites

Thank you both for your replies they have been very helpful.

 

@Yzowl We only have 1 version which is why wanting to just check for that one. The situation we are in is that we currently use Kaspersky AV but are moving to McAfee. All the PC's should have the McAfee agent on but they will be pointing to the wrong server so this needs to be reinstalled so pointing to the correct one. I'm wanting this batch to check if the correct version of McAfee is installed and if not install but if it is check which server it points to and if the wrong one reinstall itself so will be pointing to the correct server.

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...