What's the difference between Activate and "Start layer automatically"?
Lincoln asked, "we have OnPostActivate events in our layers, but they never run unless you manually de-activate and then re-activate the layers. All of our layers are set to start automatically. Shouldn't the OnPostActivate events run when SVS starts the layer during windows boot-up?"
Lincoln, you've hit on a common misunderstanding caused by the language we use in the SVS Admin interface. The menu item "Start layer automatically" is actually a typo/mistake that never got corrected and has become institutionalized. It implies that there is some sort of "start" event for the layer. But there's not. It's supposed to say, "Set as Active on Start". "Active on Start" (meaning Windows start, not the layer or SVS start) is the correct technical term. (Trinket got it right, btw.) It means as Windows is booting, the layer is visible to the system ("active"). So there's never an Activate event to trigger your OnEvent action. That is, there's never a state change because the layer is never inactive.
On Activate -- meaning someone or something somewhere executed "svscmd a" or called the Activate API -- SVS does several things:
- Runs any OnPreActivate events
- Makes the layer's content visible to the system (that is, adds it to the live redirection table)
- Emulates Windows bootup (that is, executes all startup items in Run and virgin RunOnce keys, starts up services, runs Startup folder items, etc.)
- Increments the reference count on services called (so they don’t get shut down during Deactivate if another program is using them)
- Refreshes the Explorer UI so files, folders, shortcuts, etc. become immediately visible for the interactive user
- Runs any OnPostActivate events
- Probably a few other things I'm forgetting or not aware of to ensure that everything works right
In contrast, if a layer is set "Active on Start," SVS does none of the above. When fslx.sys loads and builds its initial redirection table, the table includes all of the layers that are "Active on Start". This is very early in the boot process, before the GUI loads. To the system, the layers are just there, all of them at once, as soon as fslx.sys is done loading and building its table. Windows (not SVS) executes the startup items in active layers, just as with any other installed software.
So if you have something that you need run once before a layered app is used, you have a choice. Do it as an an SVS event at activation time (and actually do an Activate after it's delivered -- easily done in NS by selecting the "Import and Activate" program when creating your delivery task). Or do it like you would with a conventional installation, using a RunOnce key in the registry (inside the layer, of course), which -- as long as the layer is set "Active on Start" -- Windows will process normally the next time it boots.
We've noticed that a lot of customers elect not to activate layers immediately on delivery. You often rely on the "Active on Start" setting and are ok with the layer not being available for use until the next reboot. I'm not quite sure why this is so common, but it means that there may actually never be an Activate event. In this scenario, any pre-launch configuration (whether it's one-time or on every boot) would be done using conventional means, not with the SVS events system. All options for launching things during Windows startup (well, the ones we mere mortals are supposed to know about, anyway!) are documented here: http://support.microsoft.com/kb/179365. I believe most of these are familiar to packaging gurus.