PDA

View Full Version : start up script question



Gorilla
06-29-2009, 02:18 PM
Im trying to create a script that checks to see what version of symantec you have on your pc.

Since it needs to query the registry I used the REG QUERY Command. HOW CAN I ONLY GET IT ONLY GET THE 11.0.4000 and not the rest REG_SZ


Command Used
REG query "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" /v ProductVersion

RESULT
**********
H:\>REG query "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" /v Produ
ctVersion

! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC
ProductVersion REG_SZ 11.0.4000.2295
**********

WHAT I NEED
11.0.4000.2295 Displayed

Carl64
06-29-2009, 02:30 PM
Probably some fancy string manipulation needed. There doesn't seem to be a switch to only show the data.

Why not just use the Management Console to view the install version among clients? Besides the fact its a web based POS wannabe managment console.

You've also reminded me I need to update our AV. Still on 11R2!

SpireTECH
06-29-2009, 03:03 PM
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" /v ProductVersion') do (
echo %%a
)


You will probably have to change the tokens=3 to a different value. I'm guessing 5, by the registry key you are looking for.

Alterac
06-29-2009, 03:17 PM
Just use a vbscript to query the exact key, then check on that version.

Gorilla
06-30-2009, 09:30 AM
Do you guys see something wrong with this statement? I keep getting an error

FOR /F "tokens=3 delims " %%G IN (REG query "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" | FIND "ProductVersion") DO @echo %%G

SpireTECH
06-30-2009, 11:14 AM
Originally posted by Gorilla
Do you guys see something wrong with this statement? I keep getting an error

FOR /F "tokens=3 delims " %%G IN (REG query "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" | FIND "ProductVersion") DO @echo %%G

The whole statement is basically wrong. You're missing an equal sign after delims (which defaults to space anyway). And you should just use /v ProductVersion instead of find. I don't think pipe works inside a for command like that.

Anyway, I also got your PM, and now that I realize you only need to test for a specific version there is an easier way to do this.

See, you don't need to isolate the version number, you just need to test and see if the string matches the version you're looking for. This script will do what you want:


REG query "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" /v ProductVersion | FIND "11.0.4000.2295"
IF NOT ERRORLEVEL 1 SymantecUpdater.exe



That will run the SymantecUpdater.exe file if the version 11.0.4000.2295 is found. If you want it to run if that version is NOT found then remove the "NOT" from the IF statement.

Gorilla
06-30-2009, 11:39 AM
Thanks for all your help!!!