How to deploy shortcuts to %ALLUSERS%\Desktop?
Hello guys
I am really stuck in the same problem since a long time: Creating shortcuts on the “all users” desktop.
There is a .cmd script which I am executing as the program of the package. I tried it in a couple different ways (the msi are getting executed just fine, but it doesn’t create the shortcuts):Example 1:
"\\server\DistAppl\PROGRAM Common Files\PROGRAM Common Files.msi" /qn
"\\server\DistAppl\PROGRAM VBA\PROGRAM VBA Files.msi" /qn
copy /y “\\server\winapp\PROGRAM.lnk” %ALLUSERSPROFILE%\Desktop
exitExample2:
"\\server\DistAppl\PROGRAM Common Files\PROGRAM Common Files.msi" /qn
"\\server\DistAppl\PROGRAM VBA\PROGRAM VBA Files.msi" /qn
copy /y “\\server\winapp\PROGRAM.lnk” “C:\Dokumente und Einstellungen\All Users\Desktop”
exitExample3 (copied the link directly into the package folder – updated distribution points of course):
"\\server\DistAppl\PROGRAM Common Files\PROGRAM Common Files.msi" /qn
"\\server\DistAppl\PROGRAM VBA\PROGRAM VBA Files.msi" /qn
copy /y PROGRAM.lnk “C:\Dokumente und Einstellungen\All Users\Desktop”
exitExample4 (using a vbs script, which is being placed in the package folder):
"\\server\DistAppl\PROGRAM Common Files\PROGRAM Common Files.msi" /qn
"\\server\DistAppl\PROGRAM VBA\PROGRAM VBA Files.msi" /qn
call shortcuts.vbs
exitThe .vbs looks like this (and it works if you execute it manually) – probably it can’t execute it because it’s not in the working directory of the .cmd script? (-> How can I change this?)
et objShell = WScript.CreateObject("WScript.Shell")
Set objEnviron = objShell.Environment("PROCESS")
PROGRAMLinkTgt = objEnviron("ALLUSERSPROFILE") & "\Desktop\PROGRAM.lnk"
Set PROGRAMLink = objShell.CreateShortcut(PROGRAMLinkTgt)
PROGRAMLink.TargetPath = "\\server\PROGRAM\Bin\PROGRAM.exe"
PROGRAMLink.Save
The log files doesn’t help in any way, because they are just saying “failed” – but not a particular failure code or something.
Do you have any idea?
Thanks in advance and have a good day!
Regards
Answers
VB Script copies from the current directory by default in a bat file use %~dp0
Take a look at this... http://myitforum.com/cs2/blogs/jnelson/archive/2008/08/15/121348.aspx
John Marcum | http://www.TrueSec.com/en/Training.htm | http://myitforum.com/cs2/blogs/jmarcum- Marked As Answer byEric C. MattoonMSFT, ModeratorWednesday, November 04, 2009 3:29 PM
All Replies
- Side question: why are you referencing the MSIs from a UNC path instead of copying them into the package and calling them from there?
Also note that programs run with admin privileges use either the local system account or the network access account if you have it configured. Have you verified that one or both of these has read permissions on \\server\winapp?
For Examples 3 and 4 have you actually opened the desktop folder using Explorer to verify that the shortcut is not there and that the problem is not just a refresh issue?
Jason | http://myitforum.com/cs2/blogs/jsandys | http://blogs.catapultsystems.com/jsandys/default.aspx | Twitter @JasonSandys - Hey Sandy
Even though I would copy the MSIs into the package folder it would change nothing regarding the shortcuts. In this case, the msis are getting updated frequently. Anyway: In most of the packages I have the files directly within the package.
Regarding examples 3 and 4: Yes, Ive refreshed and checked the folders. Even when I am just executing a script like
call shortcuts.vbs
exit
or
copy /y PROGRAM.lnk “C:\Dokumente und Einstellungen\All Users\Desktop”
exit
it wouldn't copy/create the shortcut.
Is it probably because the UNC path is not supported and the working directory is being set to "C:\WINDOWS"? (-> and it can't find the shortcut.vbs) there?
How can I avoid that?
Thanks - I use this simple VBS script.
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\SCCMSEVER\Deployment Packages\DesktopShortcuts\*.*" , "C:\Documents and Settings\All Users\Desktop" , OverwriteExisting
Shortcuts are stored in the docktopshortcuts folder. I then deploy using software deployment cscript.exe desktopshortcuts.vbs objFSO.CopyFile "\\SCCMSEVER\Deployment Packages\DesktopShortcuts\*.*" , "C:\Documents and Settings\All Users\Desktop" , OverwriteExisting
I wouldn't hard code the path to the SCCM server in my script, that only works if you have a single server environment. It's better to copy them from the ccm\cache folder to the desktop.
John Marcum | http://www.TrueSec.com/en/Training.htm | http://myitforum.com/cs2/blogs/jmarcumI wouldn't hard code the path to the SCCM server in my script, that only works if you have a single server environment. It's better to copy them from the ccm\cache folder to the desktop.
True!
John Marcum | http://www.TrueSec.com/en/Training.htm | http://myitforum.com/cs2/blogs/jmarcum
But how can I do so? (copy them from the ccm\cache folder)
Thank you for your reply!But how can I do so? (copy them from the ccm\cache folder)
It depends on the script you are using. You could use %~dp0 in a .cmd for the current directory or left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName))) in vbscript.call %~dp0\shortcuts.vbs
pause
..unfortunately won't work.
Here is another thing: When I start the .cmd file in the UNC directory (and put a pause instead of an exit), the script returns:
'<UNC path>' is an invalid current directory path. UNC paths are not supported.
Defaulting to Windows directory.
Is it not able to start shortcuts.vbs due to that?VB Script copies from the current directory by default in a bat file use %~dp0
Take a look at this... http://myitforum.com/cs2/blogs/jnelson/archive/2008/08/15/121348.aspx
John Marcum | http://www.TrueSec.com/en/Training.htm | http://myitforum.com/cs2/blogs/jmarcum- Marked As Answer byEric C. MattoonMSFT, ModeratorWednesday, November 04, 2009 3:29 PM

