Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

How do I edit the "comments" section of a shortcut file using PowerShell?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...