A little background about what I'm trying to do and why. We are slowly migrating from using a local copy of office on our end users Win7 machines to publishing office through RDS 2012. With 2012 you can have the end users machine subscribe to a webfeed which puts the shortcuts to the actual RDP files in Appdata. In order to have our image pretty much mirror before RDS, I need to pin the shortcuts to the taskbar. If you pin the shortcut as it comes from the RDS Gateway server the icon on the taskbar is that of the .rdp file. If you edit the target for the shortcut and put mstsc.exe before the path to the .rdp file you can then pin the shortcut to the taskbar using those icons of the shortcut.
I have found posts on how to change the target field of shortcuts but nothing on how to add something to what is currently there. An environment variable is needed since the path to the shorts will be different for each user. Below is I have tried thus far
$Word = $env:appdata + "\Microsoft\Windows\Start Menu\Programs\RemoteApp and Desktop Connections\Microsoft Word 2010.lnk"$sh = New-Object -COM WScript.Shell
$targetPath = $sh.CreateShortcut($Word).TargetPath
$sh.TargetPath = "mstsc.exe" + $targetPath #Add mstsc.exe to the current target path.
$sh.Save() ## Save$shell = New-Object -COM WScript.Shell
One of the errors i'm getting is : Property 'Arguments' cannot be found on this object; make sure it exists and is settable.
I posted this question on another forum and a guy sent me the script below but it creates a new .rdp file the \RemoteApp and Desktop Connections folder named Word 2010.rdp That script is below
$Word=$env:appdata+"\Microsoft\Windows\Start Menu\Programs\RemoteApp and Desktop Connections\Microsoft Word 2010.lnk"
$sh=New-Object-COMWScript.Shell
$scObj=$sh.CreateShortcut($Word)
$scObj.TargetPath="mstsc.exe"+$scObj.TargetPath#Update the TargetPath property of the shortcut object
$scObj.Save()#Save the updated shortcut properties to the shortcut object
#Cleanup
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($sh)
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($scObj)
Remove-Variable
sh,scObj,word
Any help will be greatly appreciated.