Answered by:
User created shortcut icon lost at logoff

Question
-
Hello
I am publishing App-V applications to the users start menu. I then let the user decide if they wish to create a shortcut to the desktop or quick launch. However at log off the shortcuts icon is lost and goes blank.
The reason for it being lost is it looks like App-V creates the relevant icon at logon in %AppData%\SoftGrid Client\Icon Cache. However as the icon is recreated each time the user logs on. The previous icon that the user would have used for the shortcut is now gone and has been replaced with an icon with a different name.
It’s a Windows 7 desktop using a mandatory profile with Appsense for personalisation. I could configure Appsense to capture the %AppData%\SoftGrid Client\Icon Cache folder. But as new icons are created everytime the users logs on this would grown in size indefinitely.Wednesday, May 11, 2011 10:05 AM
Answers
-
Was having a similar issue, and I've previously posted a semi-related script to handle user created shortcuts (http://social.technet.microsoft.com/Forums/en-US/appvclients/thread/57a9a2b7-1a48-44c8-8de4-203cb4cefc76/#e44cd368-2a1e-43cc-8003-8226717bc810)...
I updated this to handle the change in icons (which are tracked in registry). The only issue of course is timing... If you execute the script on user logon, it will parse registry entries before the App-V client has a chance to perform a publishing refresh and generate new icon IDs.
I haven't really had much chance to test this yet, so feel free to expand on the ideas.
Had another thought though - if you save down the HKCU\..\Softgrid\x.x\Client\Applications keys and re-apply through AppSense, does it still generate a new icon ID for each app, or think to re-use what's already there? Again, untested.
'============================================================================================================ ' CheckVAShorts v1.1 ' Author: Sizzl (cm@phore.net) ' Modifed: 25/10/2010 - Initial build ' 18/04/2011 - Fix broken icon cache links ' ' Script Function: ' Check virtual app arrShortcuts which have been manually copied from their original location ' and are no longer within management scope ' ' Usage: ' wscript //nologo //b CheckVAShorts.vbs ' ' License: ' ' Licensed under the Apache License, Version 2.0 (the "License"); ' you may not use this file except in compliance with the License. ' You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, software ' distributed under the License is distributed on an "AS IS" BASIS, ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' See the License for the specific language governing permissions and ' limitations under the License. '============================================================================================================ On Error Resume Next const HKEY_CURRENT_USER = &H80000001 const HKEY_LOCAL_MACHINE = &H80000002 Dim strThisLocation: strThisLocation = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\")) Dim objShell: Set objShell = CreateObject("WScript.Shell") Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject") Dim strParentLocation: strParentLocation = objFSO.GetParentFolderName(strThisLocation) Dim strComputer: strComputer = "." Dim oReg: Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") '============================================================================================================ Dim arrShortcuts(150) Dim i: i = 0 Dim strKeyPath: strKeyPath = "SOFTWARE\Microsoft\SoftGrid" Dim UserPath, IconCache, AppIcon, AppVver oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys ' Look for latest App-V version For Each subkey In arrSubKeys AppVver = subKey oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath & "\" & subKey & "\Client\UserInfo\","DataDirectory", UserPath Next If Len(UserPath) < 9 then UserPath = objShell.ExpandEnvironmentStrings("%APPDATA%") & "\SoftGrid Client" End If UserPath = objFSO.GetFolder(UserPath).ShortPath IconCache = UserPath & "\ICONCA~1\" If objFSO.FileExists(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log") then objFSO.DeleteFile objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log" ' Check for non managed shortcuts and flag for update if required ' -- Desktop -- Set oFolder = objFSO.GetFolder(objShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop") For Each oFile in oFolder.Files iUpdate = 0 If LCase(Right(oFile.Name,"4")) = ".lnk" Then Set oShortcut = objShell.CreateShortcut(objFSO.GetAbsolutePathName(oFile)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then strLaunchApp = oShortcut.Arguments strLaunchApp = Replace(Right(strLaunchApp,Len(strLaunchApp)-8),"""","") if Left(oShortcut.IconLocation, Len(IconCache)) <> IconCache then iUpdate = 2 if NOT objFSO.FileExists(Left(oShortcut.IconLocation,Len(oShortcut.IconLocation)-2)) then iUpdate = 2 arrShortcuts(i) = array(oFile.Name,strLaunchApp,iUpdate,"",objFSO.GetAbsolutePathName(oFile)) i = i + 1 end if End If Next ' -- Quick Launch -- Set oFolder = objFSO.GetFolder(objShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\Internet Explorer\Quick Launch") For Each oFile in oFolder.Files If LCase(Right(oFile.Name,"4")) = ".lnk" Then Set oShortcut = objShell.CreateShortcut(objFSO.GetAbsolutePathName(oFile)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then strLaunchApp = oShortcut.Arguments strLaunchApp = Replace(Right(strLaunchApp,Len(strLaunchApp)-8),"""","") if Left(oShortcut.IconLocation, Len(IconCache)) <> IconCache then iUpdate = 2 arrShortcuts(i) = array(oFile.Name,strLaunchApp,0,"",objFSO.GetAbsolutePathName(oFile)) i = i + 1 end if End If Next Set oFolder = Nothing Dim j: j = i - 1 ' Generate list of virtual apps If NOT objFSO.FileExists(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log") then ' Generate WScript.Echo "Generating Virtual App List..." objShell.Run "cmd /c sftmime /query obj:app /short /log " & objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log",0,true If objFSO.FileExists(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log") then Dim objTS: Set objTS = objFSO.OpenTextFile(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log",1,false) Do While objTS.AtEndOfStream = false strLine = objTS.ReadLine For i = 0 to j If InStr(strLine, arrShortcuts(i)(1)) then If arrShortcuts(i)(2) < 2 then arrShortcuts(i)(2) = 1 End If Else strCompare = Left(arrShortcuts(i)(1),InStrRev(arrShortcuts(i)(1)," ")-1) if InStr(strLine,strCompare) then ' best bet arrShortcuts(i)(3) = strLine end if End If Next Loop objTS.Close Set objTS = Nothing End If End If For i = 0 to j AppIcon = "" If arrShortcuts(i)(2) = 0 then Set oShortcut = objShell.CreateShortcut(arrShortcuts(i)(4)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then oShortcut.Arguments = "/launch """ & arrShortcuts(i)(3) & """" oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath & "\" & AppVver & "\Client\Applications\" & arrShortcuts(i)(3),"Icon", AppIcon If Len(AppIcon) > 0 then oShortCut.IconLocation = objFSO.GetFile(AppIcon).ShortPath & ",0" End If oShortcut.Save WScript.Echo "Updated shortcut: " & arrShortcuts(i)(0) & ", closest match: " & arrShortcuts(i)(3) end if ElseIf arrShortcuts(i)(2) = 2 then Set oShortcut = objShell.CreateShortcut(arrShortcuts(i)(4)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then if Left(oShortcut.IconLocation, Len(IconCache)) <> IconCache then oShortCut.IconLocation = IconCache & Mid(oShortcut.IconLocation,InStrRev(oShortcut.IconLocation,"\")+1,Len(oShortCut.IconLocation)-InStrRev(oShortcut.IconLocation,"\")) end if oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath & "\" & AppVver & "\Client\Applications\" & arrShortcuts(i)(3),"Icon", AppIcon If Len(AppIcon) > 0 then oShortCut.IconLocation = objFSO.GetFile(AppIcon).ShortPath & ",0" End If oShortcut.Save WScript.Echo "Updated shortcut icon for: " & arrShortcuts(i)(0) end if End If Next
- Proposed as answer by znack Wednesday, June 8, 2011 8:04 AM
- Edited by Sizzl Wednesday, June 8, 2011 8:05 AM formatting
- Marked as answer by Aaron.ParkerModerator Saturday, December 3, 2011 11:25 AM
Wednesday, June 8, 2011 8:02 AM
All replies
-
Hello,
Does it work when using a non-mandatory profile?
/ZnackWednesday, May 11, 2011 2:40 PM -
When creating the mandatory profile template, is the App-V Client installed? If so, do you configure and refresh against the server?
Steve Thomas, SSEE, Microsoft
App-V/MED-V/SCVMM/SCCM/AppCompat
http://madvirtualizer.wordpress.com/
The App-V Team blog: http://blogs.technet.com/appv/
The MED-V Team Blog: http://blogs.technet.com/medv
The SCVMM Team blog: http://blogs.technet.com/scvmm/
“This posting is provided "AS IS" with no warranties, and confers no rights. User assumes all risks.”Wednesday, May 11, 2011 11:12 PM -
Hi Nick did you get an answer to this issue with the shortcut icon disassociating itself after the user logs off. It appears to get a new UID number to what it had previous to the logoff. this only happens to appv apps that you create a taskbar or start menue shortcut to.
Regards M
Wednesday, June 8, 2011 4:41 AM -
Was having a similar issue, and I've previously posted a semi-related script to handle user created shortcuts (http://social.technet.microsoft.com/Forums/en-US/appvclients/thread/57a9a2b7-1a48-44c8-8de4-203cb4cefc76/#e44cd368-2a1e-43cc-8003-8226717bc810)...
I updated this to handle the change in icons (which are tracked in registry). The only issue of course is timing... If you execute the script on user logon, it will parse registry entries before the App-V client has a chance to perform a publishing refresh and generate new icon IDs.
I haven't really had much chance to test this yet, so feel free to expand on the ideas.
Had another thought though - if you save down the HKCU\..\Softgrid\x.x\Client\Applications keys and re-apply through AppSense, does it still generate a new icon ID for each app, or think to re-use what's already there? Again, untested.
'============================================================================================================ ' CheckVAShorts v1.1 ' Author: Sizzl (cm@phore.net) ' Modifed: 25/10/2010 - Initial build ' 18/04/2011 - Fix broken icon cache links ' ' Script Function: ' Check virtual app arrShortcuts which have been manually copied from their original location ' and are no longer within management scope ' ' Usage: ' wscript //nologo //b CheckVAShorts.vbs ' ' License: ' ' Licensed under the Apache License, Version 2.0 (the "License"); ' you may not use this file except in compliance with the License. ' You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, software ' distributed under the License is distributed on an "AS IS" BASIS, ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' See the License for the specific language governing permissions and ' limitations under the License. '============================================================================================================ On Error Resume Next const HKEY_CURRENT_USER = &H80000001 const HKEY_LOCAL_MACHINE = &H80000002 Dim strThisLocation: strThisLocation = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\")) Dim objShell: Set objShell = CreateObject("WScript.Shell") Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject") Dim strParentLocation: strParentLocation = objFSO.GetParentFolderName(strThisLocation) Dim strComputer: strComputer = "." Dim oReg: Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") '============================================================================================================ Dim arrShortcuts(150) Dim i: i = 0 Dim strKeyPath: strKeyPath = "SOFTWARE\Microsoft\SoftGrid" Dim UserPath, IconCache, AppIcon, AppVver oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys ' Look for latest App-V version For Each subkey In arrSubKeys AppVver = subKey oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath & "\" & subKey & "\Client\UserInfo\","DataDirectory", UserPath Next If Len(UserPath) < 9 then UserPath = objShell.ExpandEnvironmentStrings("%APPDATA%") & "\SoftGrid Client" End If UserPath = objFSO.GetFolder(UserPath).ShortPath IconCache = UserPath & "\ICONCA~1\" If objFSO.FileExists(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log") then objFSO.DeleteFile objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log" ' Check for non managed shortcuts and flag for update if required ' -- Desktop -- Set oFolder = objFSO.GetFolder(objShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop") For Each oFile in oFolder.Files iUpdate = 0 If LCase(Right(oFile.Name,"4")) = ".lnk" Then Set oShortcut = objShell.CreateShortcut(objFSO.GetAbsolutePathName(oFile)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then strLaunchApp = oShortcut.Arguments strLaunchApp = Replace(Right(strLaunchApp,Len(strLaunchApp)-8),"""","") if Left(oShortcut.IconLocation, Len(IconCache)) <> IconCache then iUpdate = 2 if NOT objFSO.FileExists(Left(oShortcut.IconLocation,Len(oShortcut.IconLocation)-2)) then iUpdate = 2 arrShortcuts(i) = array(oFile.Name,strLaunchApp,iUpdate,"",objFSO.GetAbsolutePathName(oFile)) i = i + 1 end if End If Next ' -- Quick Launch -- Set oFolder = objFSO.GetFolder(objShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\Internet Explorer\Quick Launch") For Each oFile in oFolder.Files If LCase(Right(oFile.Name,"4")) = ".lnk" Then Set oShortcut = objShell.CreateShortcut(objFSO.GetAbsolutePathName(oFile)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then strLaunchApp = oShortcut.Arguments strLaunchApp = Replace(Right(strLaunchApp,Len(strLaunchApp)-8),"""","") if Left(oShortcut.IconLocation, Len(IconCache)) <> IconCache then iUpdate = 2 arrShortcuts(i) = array(oFile.Name,strLaunchApp,0,"",objFSO.GetAbsolutePathName(oFile)) i = i + 1 end if End If Next Set oFolder = Nothing Dim j: j = i - 1 ' Generate list of virtual apps If NOT objFSO.FileExists(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log") then ' Generate WScript.Echo "Generating Virtual App List..." objShell.Run "cmd /c sftmime /query obj:app /short /log " & objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log",0,true If objFSO.FileExists(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log") then Dim objTS: Set objTS = objFSO.OpenTextFile(objShell.ExpandEnvironmentStrings("%TEMP%") & "\vapps.log",1,false) Do While objTS.AtEndOfStream = false strLine = objTS.ReadLine For i = 0 to j If InStr(strLine, arrShortcuts(i)(1)) then If arrShortcuts(i)(2) < 2 then arrShortcuts(i)(2) = 1 End If Else strCompare = Left(arrShortcuts(i)(1),InStrRev(arrShortcuts(i)(1)," ")-1) if InStr(strLine,strCompare) then ' best bet arrShortcuts(i)(3) = strLine end if End If Next Loop objTS.Close Set objTS = Nothing End If End If For i = 0 to j AppIcon = "" If arrShortcuts(i)(2) = 0 then Set oShortcut = objShell.CreateShortcut(arrShortcuts(i)(4)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then oShortcut.Arguments = "/launch """ & arrShortcuts(i)(3) & """" oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath & "\" & AppVver & "\Client\Applications\" & arrShortcuts(i)(3),"Icon", AppIcon If Len(AppIcon) > 0 then oShortCut.IconLocation = objFSO.GetFile(AppIcon).ShortPath & ",0" End If oShortcut.Save WScript.Echo "Updated shortcut: " & arrShortcuts(i)(0) & ", closest match: " & arrShortcuts(i)(3) end if ElseIf arrShortcuts(i)(2) = 2 then Set oShortcut = objShell.CreateShortcut(arrShortcuts(i)(4)) if InStr(LCase(oShortcut.targetpath),"sfttray.exe") then if Left(oShortcut.IconLocation, Len(IconCache)) <> IconCache then oShortCut.IconLocation = IconCache & Mid(oShortcut.IconLocation,InStrRev(oShortcut.IconLocation,"\")+1,Len(oShortCut.IconLocation)-InStrRev(oShortcut.IconLocation,"\")) end if oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath & "\" & AppVver & "\Client\Applications\" & arrShortcuts(i)(3),"Icon", AppIcon If Len(AppIcon) > 0 then oShortCut.IconLocation = objFSO.GetFile(AppIcon).ShortPath & ",0" End If oShortcut.Save WScript.Echo "Updated shortcut icon for: " & arrShortcuts(i)(0) end if End If Next
- Proposed as answer by znack Wednesday, June 8, 2011 8:04 AM
- Edited by Sizzl Wednesday, June 8, 2011 8:05 AM formatting
- Marked as answer by Aaron.ParkerModerator Saturday, December 3, 2011 11:25 AM
Wednesday, June 8, 2011 8:02 AM