could you help me with this? I am trying to change the comments section of some shortcuts with PowerShell. If I were to try $link.Description = "dog"
, the comments section is changed to "dog". But when I try $link.Description = $newDescription
, nothing appears in the comments section even though it should say "cat". Here is some of the code:
function Set-Shortcut {
param
(
[Parameter(ValueFromPipelineByPropertyName=$false)]
$LinkPath = $fileName,#pick the shortcut
$Hotkey,
$IconLocation,
$Arguments,
$TargetPath,
$Description
)
begin {
$shell = New-Object -ComObject WScript.Shell
}#end begin
process {
$link = $shell.CreateShortcut($LinkPath)
$newDescription = "cat"
$link.Description = $newDescription
$PSCmdlet.MyInvocation.BoundParameters.GetEnumerator() |
Where-Object { $_.key -ne 'LinkPath' } |
ForEach-Object { $link.$($_.key) = $_.value }
$link.Save()
}#end process
}#end Set-Shortcut
question from:
https://stackoverflow.com/questions/65911616/how-do-i-edit-the-comments-section-of-a-shortcut-file-using-powershell 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…