使用Powershell编辑快捷方式(.lnk)属性 [英] Editing shortcut (.lnk) properties with Powershell

查看:1461
本文介绍了使用Powershell编辑快捷方式(.lnk)属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一个讨厌的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\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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆