Reputation: 1832
I've got a script that is currently using a WScript.Shell COM object to create a shortcut.
$shortcut = (New-Object -ComObject WScript.Shell).Createshortcut("$shortcutFolder\target.lnk")
Unfortunately, setting the target path of the shortcut...:
$shortcut.TargetPath = $targetPath
...is taking a very long time (30 to 75 seconds) if it has not been done previously in the current Powershell session. If, however, the command is run again, its time to execute is on the order of milliseconds as it should be.
Is there another, maybe native, way to accomplish this that will work better? Alternatively, is there anything I can do to speed this process up? I've got a Process Monitor trace, but I haven't been able to glean much from it.
Upvotes: 1
Views: 426
Reputation: 202072
IIRC the WScript API is just a thin layer on top of the IShellLink COM interface which is what we use in our New-Shortcut cmdlet in the PowerShell Community Extensions. What is the type in $targetPath
e.g. what type info does this return:
$targetPath | get-member
Upvotes: 1