将. link复制到64位Windows上会改变快捷方式的内容



我们使用SCCM 2012 R2, server 2012服务器和Windows 7客户端。学生电脑通常是Win7-64。

我创建了一个脚本来安装Eclipse,基本上,创建一个目录并复制文件(Eclipse没有安装程序,是32位软件)。在我的脚本中,为了让学生更方便,我想在桌面和开始菜单中添加快捷方式。代码如下:

REM Put icon on desktop
copy "Eclipse Mars (64).lnk" "C:UsersPublicDesktop"
rename "C:UsersPublicDesktopEclipse Mars (64).lnk" "C:UsersPublicDesktopEclipse Mars.lnk"

然而,当链接出现在客户端桌面上时,正确的目标"C:Program Files (x86)Eclipse Eclipse .exe"更改为"C:Program FilesEclipse Eclipse .exe",因此不起作用(与Start In相同)。

如何将快捷方式内容更改到错误的程序文件目录?

最后,虽然我在这个例子中提到了Eclipse,但是在64位机器上编写任何32位快捷方式都会发生这种情况。

我做了一些研究,你应该试试这个:

ren "Eclipsce Mars (64).lnk" eclm.tmp
copy "eclm.tmp" "C:UsersPublicDesktop"
ren "C:UsersPublicDesktopeclm.tmp" "C:UsersPublicDesktopEclipse Mars.lnk"
ren eclm.tmp "Eclipsce Mars (64).lnk"

我做了什么:

  1. 将原.lnk重命名为eclm.tmp
  2. 复制eclm.tmpDesktop
  3. Desktopeclm.tmp重命名为Eclipse Mars.lnk
  4. 将原.lnk重命名为正常

应该绕过Windows更改.lnk文件内容的趋势。

如果这有效,请在评论和投票柜台告诉我!
div CSS ~

您可以使用一个简单的VBS脚本创建真正的Windows快捷方式,该脚本可以从主批处理文件中调用。

主批处理文件

REM Put icon on desktop
call "Create Shortcut.vbs" "C:UsersPublicDesktopEclipse Mars (64).lnk" "C:Program Files (x86)eclipse-marseclipse.exe" "C:Program Files (x86)eclipse-mars"

VBS "Create Shortcut.vbs":

' Check the number of parameters
If 3 <> WScript.Arguments.Count Then
    WScript.Echo "Please call this file using the following parameters:"
    WScript.Echo
    WScript.Echo "   LINK PATH   - Absolute path where the shortcut file will be created"
    WScript.Echo "   TARGET_PATH - Absolute path of the target program"
    WScript.Echo "   WORKING_DIR - Working directory used by this shortcut"
    WScript.Quit(1)
End If
strLinkPath   = WScript.Arguments(0)
strTargetPath = WScript.Arguments(1)
strWorkingDir = WScript.Arguments(2)
set oShell = WScript.CreateObject("WScript.Shell")
set oShellLink = oShell.CreateShortcut(strLinkPath)
oShellLink.TargetPath       = sTargetPath
oShellLink.WorkingDirectory = strWorkingDir
oShellLink.WindowStyle      = 1
oShellLink.Description      = ""
oShellLink.IconLocation     = strTargetPath
oShellLink.Save

最新更新