PowerShell copy shortcut to Public Desktop

Looking for a good way to create Desktop shortcuts for users. I have the K1100 and have tried the script wizard that is built in but for some reason it doesn't seem to work.

Try with this VBScript

Option Explicit
On Error Resume Next

Dim objShell,lnk,ProgramFiles,PublicFold

Set objShell = CreateObject["WScript.Shell"]
ProgramFiles=objShell.ExpandEnvironmentStrings["%ProgramFiles%"]
PublicFold=objShell.ExpandEnvironmentStrings["%Public%"]


Set lnk = objShell.CreateShortcut[PublicFold & "\Desktop\MyShortcut.LNK"]

lnk.TargetPath = ProgramFiles & "\MyApp\MyProgram.exe"
lnk.Arguments = ""
lnk.Description = "MyProgram"
lnk.HotKey = "ALT+CTRL+F"
lnk.IconLocation = ProgramFiles & "\MyApp\MyProgram.exe, 0"
lnk.WindowStyle = "1"
lnk.WorkingDirectory = ProgramFiles & "\MyApp"
lnk.Save
Set lnk = Nothing

Set objShell = Nothing

WScript.Quit

Zip all of your shortcuts [.lnk] up along with a .cmd file. Call your .cmd in the install command like you usually would.

@echo off

copy /y shortcut.lnk "%public%\desktop"

copy /y shortcut2.lnk "%public%\desktop"

copy /y shortcut3.lnk "%public%\desktop"

Posted by: jknox 8 years ago

It's usually easiest in my experience to just use a kscript that unzips the link to All Users desktop.

Not a KACE method, but you can use GPO to create shortcuts:

//technet.microsoft.com/en-us/library/cc753580.aspx

I would assume that you are targetting systems that are Windows Vista and above since you are using thePublic profile for All Users. Also, you are getting the "%ProgramFiles%" variable and not the "%ProgramFiles[x86]%" variable so you must be either only running on 32-bit or the software is 64-bit. Either way, the below script works just fine for me.

Option Explicit
On Error Resume Next

Dim objShell, lnk, ProgramFiles, PublicFold

Set objShell = WScript.CreateObject["WScript.Shell"]
ProgramFiles = objShell.ExpandEnvironmentStrings["%ProgramFiles%"]
PublicFold = objShell.ExpandEnvironmentStrings["%PUBLIC%"]

Set lnk = objShell.CreateShortcut[PublicFold & "\Desktop\MyShortcut.lnk"]
lnk.TargetPath = ProgramFiles & "\MyApp\MyProgram.exe"
lnk.Arguments = ""
lnk.Description = "MyProgram"
lnk.HotKey = "ALT+CTRL+F"
lnk.IconLocation = ProgramFiles & "\MyApp\MyProgram.exe, 0"
lnk.WindowStyle = "1"
lnk.WorkingDirectory = ProgramFiles & "\MyApp"
lnk.Save


Set objShell = Nothing
Set lnk = Nothing
ProgramFiles = Null
PublicFold = Null

Video liên quan

Chủ Đề