通过自动脚本重新格式化 Windows lnk 文件

发布于 2024-07-10 08:36:11 字数 338 浏览 7 评论 0原文

问题:C盘上有一堆指向J:盘的.lnk文件,但是J:盘已经消失了,取而代之的是P:盘。 人们已经采取了各种技巧来让 .lnk 文件仍然可以工作,但它变得很烦人,是时候修复这些问题了。

使用 Ruby、Python、WSH.JScript 或 Perl,您可以迭代 .lnk 文件的整个目录树并更改它们,使它们指向 p:/* 而不是 j:/* 吗? 你会怎样做呢?

注意:这对我来说并不是完全未知,但我还是提出了这个问题,因为到目前为止我发现的用于管理 .lnk 文件的 API 似乎太麻烦了,无法成为最知名的方式这样做的。 这是那些绝望的“必须有更好的方法”类型的问题之一。

Problem: There are a bunch of .lnk files on the C drive that point to the J: drive, but the J: drive is gone, and the P: drive has replaced it. Various tricks have been done to get the .lnk files to still work anyway, but it's getting annoying, and it's time to just fix the things.

Using Ruby, Python, WSH.JScript or Perl, can you iterate through an entire directory tree of .lnk files and change them so they point to p:/* instead of j:/*? How would you go about it?

Note: This is not a total unknown to me, but I ask the question anyway because the API for managing .lnk files in the ways I've found so far seem too cumbersome to be the best known way of doing this. This is one of those desparate "there's got to be a better way" type questions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏末 2024-07-17 08:36:12

在 WindowsNT 资源工具包中,有一个名为 Shortcut.exe 的命令行实用程序,据我可靠地告知,该实用程序也可以在 XP/2000/2003 下运行。 您可以使用各种命令行开关来修改现有的 LNK 文件以指向新的快捷方式。

我在这里找到了有关它的信息:
http://www.ss64.com/nt/shortcut.html

我敢说它可以在 Microsoft 网站上找到并提取 WindowsNT 资源工具包并不难。 它是一个命令行实用程序,因此您应该能够对其进行批处理以循环遍历所有 LNK 文件并修改它们以使它们正确。

In the WindowsNT Resource Kit there's a command line utility called Shortcut.exe that I'm reliably informed will run under XP/2000/2003 as well. You can use a variety of command line switches to modify existing LNK files to point to new shortcuts.

I found information about it here:
http://www.ss64.com/nt/shortcut.html

I daresay it can't be too hard to hunt down the WindowsNT Resource Kit on the Microsoft Website and extract it. It's a command line utility, so you should be able to batch it to loop through all the LNK files and modify them so they're correct.

墟烟 2024-07-17 08:36:12

我们发现这个 VB 脚本运行良好。

http://www.enterpriseitplanet.com/resources/scripts_win/article.php/ 3081941

一些警告:

小心! 它从驱动器的根目录运行。 如果您在自己的计算机上进行测试,则可能会面临重新映射所有 Windows 快捷方式的风险 - 例如。 那些在你的开始菜单上! 我们稍微编辑了脚本以获得更多控制(在 Main() 方法内):

   dim onlyFolder
    Set onlyFolder =fso.GetFolder("C:\") 
    SearchFolder onlyFolder

'   for each aDrive in fso.Drives       
'       if aDrive.DriveType = 2 then
'           SearchFolder aDrive.RootFolder
'       end if
'   next

fixlinks.ini 文件不喜欢空行,它必须是偶数行。

它在后台运行,可能会弹出困难目录的权限错误。 除了最后的确认窗口之外,很难判断它何时完成。 可能最好在 Process Explorer 中关注它,并在 Vista/etc 上以管理员身份从命令 shell 运行它。

除此之外,效果很好!

We found this VB Script which works fine.

http://www.enterpriseitplanet.com/resources/scripts_win/article.php/3081941

Some warnings:

Careful! It runs from the root of the drive. If you test it on your own machine, you risk remapping all your Windows shortcuts - eg. those on your Start Menu! We edited the script slightly to get a bit more control (within the Main() method):

   dim onlyFolder
    Set onlyFolder =fso.GetFolder("C:\") 
    SearchFolder onlyFolder

'   for each aDrive in fso.Drives       
'       if aDrive.DriveType = 2 then
'           SearchFolder aDrive.RootFolder
'       end if
'   next

The fixlinks.ini file doesn't like empty lines, it has to be an even number of lines.

It runs in the background and may pop up permission errors for difficult directories. It's difficult to tell when it has finished, except for the confirmation window at the end. Probably best to keep an eye on it in Process Explorer, and run it from a command shell as Administrator on Vista/etc.

Other than that, worked great!

冷血 2024-07-17 08:36:12

只需使用 JAFAT 取证分析工具项目存档 中的 lnk 文件解析器即可。

请参阅 http://jafat.sourceforge.net 上的 lnk-parse-1.0.pl

似乎没有任何依赖项(尤其是不糟糕的 Windows 材料)。 语法很简单,链接文件在标准输出中变成简单的文本。

Simply use lnk file parser at J.A.F.A.T. Archive of Forensics Analysis Tools project.

See lnk-parse-1.0.pl at http://jafat.sourceforge.net

There seems no have no dependencies (and notably not awful Windows material). Syntax is simple and link file becomes a simple text in standard output.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文