Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Autostart executable stored in the layer

Created: 24 May 2013 | 18 comments

Hello

We have a package which is streamed down to workstation. How can we automatically start and executable from within the layer?

No action event allows to start an executable that is in the package.

Alexander

Operating Systems:

Comments 18 CommentsJump to latest comment

Ganesh.B's picture

Hi Alexander,

  Are you streaming the application from portal or pushing it to client machine via Prepop of package?  Also, are you trying to start an executable within the layer, every time a machine starts or only for the first time after streaming? 

When you stream an application from portal, it should launch the executable which you've clicked

ad0170's picture

Hello

On workstations we use Symantec Workspace Streaming Agent to downloads package from Streaming Server.

Symantec Workspace Streaming Agent streams down a package to workstation and automatically activates a layer.

Once layer is activated, we want an executable stored in the layer to start automatically.

We do not want a user to manually click an executable to start.

The post activation even is able to start a script/executable that is on the base. It is not able to start an executable stored in the layer.

Alexander

delvalled's picture

Hi Alexander,

The layer must be active (accessible) before you can start an executable within the layer. The following events take place while the layer is accessible:

  • Post Activate
  • Pre Deactivate
  • Pre Execution
  • Post Execution

Post Activate and Pre Deactivate are useful if the process only needs to run one time after you activate or once before you deactivate the layer.

Pre and Post Execution is useful if you need to run a process every time before you launch the applcation or everytime after the application exits.

Regards,

Danny

ad0170's picture

Hello Danny

I am quite familiar with all those event actions you have mentioned. However none of them does the trick.

On workstation Symantec Workspace Streaming Agent downloads a package to workstation and it automatically activates a layer.

And at that point in tim we want to run a executable that is stored in the layer.

Post Activate is able to run only a script/executable that is stored on workstation, it is not able to run any executable that is stored in the layer.

Other event actions are not good because they run after an executable from the layer has been started.

Alex

ateamrh's picture

Hi Alexander,

You can use the PostActivate event to execute a vbscript which will execute the program from the layer.

You need to place the vbscript in the Meta folder on the read only layer and then point the PostActivate event to the vbscript using this string:

c:\windows\system32\wscript.exe %VZ_LAYER_METADIR%\'name of vbscript'.vbs

The variable %VZ_LAYER_METADIR% is a variable which points to the Meta dir of the Read only layer from the layer its used from.

Kind Regards

Martin

ad0170's picture

Hello Martin

It looks to me like, your suggestion with post activate vbscript is the only solution.

Thank you for the idea.

Alexander

ad0170's picture

Martin

I have tried post activate event vb script to start an executable from within the layer and it works.

But, that script runs under SYSTEM account.

How to make post activate script to run under user account? When you define the script, the check box Run with User Privileges is greyed out.

Alexander

delvalled's picture

Alexander,

Let me try to address this question:

How to make post activate script to run under user account? When you define the script, the check boxRun with User Privileges is greyed out.

When using the PostActivate event with Symantec Workspace Streaming (SWS), the script always executes in the SYSTEM context because non-privileged users cannot activate layers. 

Instead of PostActivate, I'll use the PreExecution event when I need to run scripts under a user account.

PreExec event in Composer.png

Please note, your script will run everytime you launch the application. Depending on your situation, this may be okay, but I only need my script to run one time, so I'll check to see if a registry value exists, and if it doesn't exist, I'll continue to run my script, then I'll add the registry value so the script will just exit the next time I launch the application:

:CHECK
REG QUERY HKLM\System\SomeRegistryKey /v SomeValueName
IF %errorlevel%==1 (goto RUN) else (goto END)
 
:RUN
ECHO Insert your script actions below, for example:
ECHO This script executed at %time% on %date%. >> %userprofile%\desktop\PreExecution.txt
 
ECHO After your actions complete, add the following data to the registry:
REG ADD HKLM\System\SomeRegistryKey /v SomeValueName /t REG_SZ /d "Create this registry key and value pair so we won't run again."
 
:END
ECHO 1 > %1

You can determine that the preinstallation event ran under the user account using a utility like Process Monitor:

Launch lifecycle1.png

I hope this help!

Kind regards,

Danny

ad0170's picture

Hello Danny

We need to do something with the virtualized application SnagIT. We need to make the virtualized SnagIT work the same way as naturally installed one:

1./ Once a user logs in, the program snagit32.exe is automatically started (user does not need to click anything to start the program). SnagIT reads user preferences so it know how to operate.

2./ Thus, after the SnagIT start, once user hits the key "PrintScreen" SnagIT intercepts this key hit event and displays its crosshair to start capturing the image on the screen.

Well, this is what is happening on virtualized SnagIT:

1./ Once user logs in, SnagIT is automatically streamed down to workstation and the layer is automatically activated - so far so good.

2./ we cannot use post activation script to automatically start SnagIT because it does not run under user priviledges, and so it does not read user preferences.

we cannot use pre execution script, because user does not want to double-click on SnagIT to start it. User wants SnagIT to start automatically without his intervention.

So is there some other way how to make snagIT start automatically under user priviledges after user log in?

Alexander

delvalled's picture

Hello Alexander,

The picture is coming into focus now! When SWS installs a layer, SWS does not ask the startup actions to run because the "user" activating the layer is the SYSTEM account instead of the logged-on user.

When SnagIT is installed, it creates a shortcut in ..\Start Menu\Programs\Startup and specifies to run the Snagit32.exe application minimized. We need to create a script that imitates this startup action of SnagIT. Here's a sample you can copy:

start "" /D"%ProgramFiles%\TechSmith\Snagit 11\" /MIN "%ProgramFiles%\TechSmith\Snagit 11\Snagit32.exe"
echo 1 > %1

Next, add this script using a PostInstallation event and select the option to run with user privileges:

Start_SnagIt event.png

Lastly, I uploaded the package to my streaming server and I also set the package to pre-cache package and provisioned to my user account.

To test it, I logged into my client and noticed that SnagIT package begins installation automatically.

Installing SnagIT.png

A few moments after caching begins, I notice the SnagIT icon appears in the system tray automatically:

PostInstall SnagIT running in systray.png

Using the PostInstallation event to mimic SnagIT's startup action allows the application to start automatically without user intervention. I can now press the "print screen" key and SnagIT displays its crosshair.

Please test this in your environment and share the results with us!

Kind regards,

Danny

ateamrh's picture

Hi Danny and Alexander,

As far as I can see this is not a solution, since the PostInstallation event is only run during the first streaming of the package. When a user reboots and login again and allready have the package in the cache, it will not run the PostInstallation event again, and hence thereby not autostart SnagIT.

Just an idea, maybe it will work if the entry in the startup folder is there (the shortcut which SnagIT creates) and then activate the SLAM feature of the streaming agent. Maybe (not tested from my side) SLAM activates the package before the user logon process is completed, and since windows logon manager processes the startup folder as the last run/runonce feature as far as I rememeber, the shortcut in the startup folder will active SnagIT in the user content. Remember that this is just an idea and not something I have tested.

Kind Regards

Martin

ad0170's picture

Danny

Unfortinately, the solution you provide do not work in our environment. Program does not start automatically by post install script.

Any other suggestion?

Alex

ateamrh's picture

Hi Alexander,

Try to modify this vbscript.to your needs, we use it to display text to the current logged on user, when the script is executed as system account.

strComputer = "."
strDomainPrefix = "DOMAINNAME\" 'Set this to your actual domainname, i.e. WINDOM -
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
Wscript.Echo "User Name = " & objComputer.UserName _
& VBNewLine & "Computer Name = " & objComputer.Name

If objComputer.Username <> "" Then ' There is a user logged on locally.
Username = Replace(objComputer.Username, strDomainPrefix, "") ' This will fail, if no user is logged on locally.
End If
WScript.Echo objComputer.UserName
WScript.Echo Username
WScript.Echo objComputer.Domain

Txt = "Text to current user goes here..."
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("msg " & Username & " " & Txt, 1, true)

Next

Kind Regards

Martin

ateamrh's picture

Hi Alexander,

Found a easy way to get snagit started. It's a nice undocumented feature of SWV/SWS (Thanks Jordan for hint)

If you add a registry key with the path to snagit to a run registry under the USER_TEMPLATE\Software\Microsoft\Windows\CurrentVersion\Run then SWV/SWS emulates the key when the layer is activated and starts snagit.

For the test I created a REG_SZ key with the name Snagit and a value of "%ProgramFiles(x86)%\TechSmith\Snagit 11\Snagit32.exe" and it worked perfectly.

SWV/SWS emulates the RUN and RUNONCE keys as they would have run during a logon.

Unfortunaly it do not seem like it emulates the startup folder.

Happy Packaging yes

Kind Regards

Martin

ad0170's picture

Hello Martin

The registry key Run does really work well on a computer running Symantec Workspace Virtualization Admin.

However, if you deliver application to workstation via Symantec Workspace Streaming Agent that Run key is ignored and Snagit does not start automatically.

Alexander

ateamrh's picture

Hi Alexander,

Have just done some more testing and it seems like that when you stream the package it do not activate executables in run registry or in the COMMONSTARTUP and STARTUP folders during import and activation.

But if you log off/log on or restart the client it does execute them.

I have filled a bug report for 7.5 on this issue, and are awaiting symantec.
Still testing on 6.1.
 

Kind Regards

Martin

ad0170's picture

Hello Martin

This is our finding as well. We still use Streaming Agent 6.1. Streaming Agent does not work the same way as Workspace Admin.

Alexander

ateamrh's picture

Hi Alexander,

If you haven't got it to work yet I have found a workaround that works.

First add and Run registry entry under either HKLM or HKCU which starts snagit in the package.
Next create and PostInstallation event as described by Danny.

This way the PostInstallation will execute when the package are streamed the first time and the Run entry will execute everytime a user logs on the machine after the package have been streamed to the machine.

Kind Regards
Martin