使用 Powershell 编辑快捷方式 (.lnk) 属性 [英] Editing shortcut (.lnk) properties with Powershell
问题描述
我发现了一种讨厌的 VBS 方法来执行此操作,但我正在寻找一种本机 PoSh 程序来编辑 .LNK 文件的属性.目标是联系远程机器,复制具有大部分正确属性的现有快捷方式,并编辑其中的几个.
I've found a nasty VBS way to do this, but I'm looking for a native PoSh procedure to edit the properties of a .LNK file. The goal is to reach out to remote machines, duplicate an existing shortcut with most of the correct properties, and edit a couple of them.
如果能更轻松地编写新的快捷方式文件,那也行.
If it would just be easier to write a new shortcut file, that would work too.
推荐答案
Copy-Item $sourcepath $destination ## Get the lnk we want to use as a template
$shell = New-Object -COM WScript.Shell
$shortcut = $shell.CreateShortcut($destination) ## Open the lnk
$shortcut.TargetPath = "C:path o
ewexe.exe" ## Make changes
$shortcut.Description = "Our new link" ## This is the "Comment" field
$shortcut.Save() ## Save
在这里找到了 VB 版本的代码:http://www.tutorialized.com/view/tutorial/Extract-the-target-file-from-a-shortcut-file-.lnk/18349
Found the VB version of the code here: http://www.tutorialized.com/view/tutorial/Extract-the-target-file-from-a-shortcut-file-.lnk/18349
这篇关于使用 Powershell 编辑快捷方式 (.lnk) 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!