Layer scripting help

This issue has been solved. See solution.
trb48's picture

 I am trying to add some logic into a script that I am working with. I would like the script to determine if a layer is present on the computer, if it is, the script does X. If the layer is missing the script will do Y. I have looked at SVSCMD.exe and I can't find anything that would let me determine if the layer is present or not. Any suggestions?

Jordan's picture

You could use WMI (VBS or

You could use WMI (VBS or .Net) or the API (C++ or .Net) to do this by either GUID (best) or Layer Name, you could also use the Command line but it would be harder.  Let me know what you're environment is and I'll help.

If a forum post solves your problem please flag is as the solution

I you like an article, blog post or download vote it up

trb48's picture

 I am not a coder, so I feel

 I am not a coder, so I feel more comfortable using the command line...

Thanks for your willingness to help!

Jordan's picture

You can use REG COMPARE(type

You can use REG COMPARE(type reg compare /? in the command line for info) to check to see if a specific GUID or name exists under HKLM\SYSTEM\Altiris\FSL\  you'll have to cycle through all the magic numbers because those can be different on each machine by using the /s (subkey) flag.  REG COMPARE will return a 0 if it finds what you're looking for.

What you'll be looking for is ID and NAME under the magic number.

WMI would be like this (which I recommend)

strComputer = "."
SET objWMIService = GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default" )
SET colItems = objWMIService.ExecQuery( _
"Select * from VirtualSoftwarePackage Where GUID=myGUID" )
FOR EACH objItem IN colItems
'do my layer import or whatever
NEXT

More here. https://www-secure.symantec.com/connect/articles/s...

If a forum post solves your problem please flag is as the solution

I you like an article, blog post or download vote it up

AngelD's picture

A Quick Way to Write SVS Scripts

We've had some previous discussion regarding scripting for SVS in various languages, check out A Quick Way to Write SVS Scripts

erikw's picture

Easy solution

You can do the VBscript and use it as an onevent.
That's usually the way I handle this kind of tricky stuff.
In the new SWV this will be default technologie.

Regards
Erik
www.DinamiQs.com
Dinamiqs is the home of VirtualStorm (www.virtualstorm.org)

Jeremy_Hurren's picture

Easy way to accomplish with cmd/bat files

Solution

You can use the layer properties command and then check the errorlevel afterward. So, I use something like the following...

@echo off
svscmd.exe "MyLayerGuid" p >NUL
if errorlevel 1 (
echo Layer is not there
) else (
echo Layer is there
)