Useful MDT Script: Copy Shortcut as an Application

If you’ve ever been involved in a Desktop Rollout or Refresh, I’m sure you’ve heard a user ask “Why isn’t (insert name of shortcut to website here) installed?” Well, I have a script for this that should prevent this conversation from even happening in the first place.

I’ve always kind of found these requests strange since it’s not a program that’s installed in the traditional sense, users simply want a shortcut to webpage on their desktop.

Now, I’m sure most of you are thinking, “Just put the shortcut in the reference image.” – But I have a much slicker way. Script it and add it as an app in your deployment share, because if we put it in our reference image EVERYBODY gets it, which clutters desktops, and worse yet limits the oh so glorious flexability of MDT. This way, we’re in control of who gets what.

The idea here is stupid simple:  use a script that does one thing and one thing remarkably well and that is copy one .lnk file from the share to the public desktop at deploy time. This way we can ensure only payroll people get the payroll webapp and only managers get the managers webportal link.

objFSO.CopyFile \\ServerName\DeploymentShare$\Applications\Webapp\Webapp.lnk, “C:\Users\Public\Desktop\Webapp.lnk”

Side note: Yes, I know this can also be done with Active Directory, but I’m trying to illustrate that we can leverage MDT to run custom scripts to do simple things like copy a file from a share to the public desktop on a workstation, as this also works remarkably well for simple .exes that sit on fileshares.

 

SEE VBSCRIPT BELOW

' //******************************************************
' //
' // Purpose: Copies any shortcut from the deployment share to the public user desktop
' // Usage: cscript CopyShortcut [/debug:true]
' // Author: MDTGuy.WordPress.com
' // Disclaimer: The script was NOT put together by a REAL programmer, so it's AS IS dude.
' //
' //******************************************************

'On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0

'//---------------------------------------------------------------------------
'//
'// Function: ZTIProcess()
'//
'// Input: None
'//
'// Return: Success - 0
'// Failure - non-zero
'//
'// Purpose: Perform main ZTI processing
'//
'//---------------------------------------------------------------------------

Function ZTIProcess()
iRetVal = Success
ZTIProcess = iRetval

Dim sName,objFSO

sName = "CopyShortcut"

oLogging.CreateEntry sName & " Copy Starting", LogTypeInfo

set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\DeploymentServer\DeploymentShare$\Applications\Shortcut\Shortcut.lnk", "C:\Users\Public\Desktop\Shortcut.lnk"

oLogging.CreateEntry sName & " Copy Complete", LogTypeInfo

End Function

Advertisements