powershell - 使用 Powershell 编辑快捷方式 (.lnk) 属性

标签 powershell file shortcut

我找到了一种讨厌的 VBS 方法来执行此操作,但我正在寻找一个本地 PoSh 程序来编辑 .LNK 文件的属性。目标是联系远程机器,复制具有大多数正确属性的现有快捷方式,并编辑其中的几个。

如果编写新的快捷方式文件更容易,那也可以。

最佳答案

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\to\new\exe.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

关于powershell - 使用 Powershell 编辑快捷方式 (.lnk) 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/484560/

相关文章:

C++-在文本文件上写入时代码无法换行

html - 粘贴多行的快捷方式 - Sublime Text 2

java - 如何从 java 中的文本文件创建字符串数组列表?

c# - 如何从方法返回文件类型

xcode - 获取在 Xcode 4 中工作的快捷方式记录器

firefox - Firefox 是否有清除缓存的键盘快捷键?

powershell - 命名 PowerShell 动词的良好准则是什么?

powershell - 删除早于 xx 天的文件

powershell - 查找字符串中任何一个数组元素的首次出现-Powershell

PowerShell Switch 语句问题