0

我对此真的很陌生,所以请原谅我的无知。我们有大量安装了office 2003 专业版的XP 机器。我们有一个登录脚本,用于在用户桌面上放置 WORD EXCEL POWERPOINT OUTLOOK 和 ACCESS 2003 图标的图标。但是有些机器现在安装了 office 2010 而不是 2003,我不确定如何修改现有脚本以考虑到这一点并提供正确的图标集。

仅适用于 2003 年办公室的现有脚本是


Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _ 
    "\Microsoft Word 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\winword.exe"
objShortCut.Description = "Microsoft Word 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Excel 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\excel.exe"
objShortCut.Description = "Microsoft Excel 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Powerpoint 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\powerpnt.exe"
objShortCut.Description = "Microsoft Powerpoint 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Access 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\msaccess.exe"
objShortCut.Description = "Microsoft Access 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Outlook 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\outlook.exe"
objShortCut.Description = "Microsoft Outlook 2003"
objShortCut.Save        

我已经复制了上面的代码并修改了路径以反映 Office 到 2010 的版本更改,但这也会在用户桌面上为缺少的版本放置无效的快捷方式

我的代码是


' * ** * ** * ** * ** * ** * ** * ** '* office 2003 链接起点 * ' * ** * ** * ** * ** * ** * ** * **

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _ 
    "\Microsoft Word 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\winword.exe"
objShortCut.Description = "Microsoft Word 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Excel 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\excel.exe"
objShortCut.Description = "Microsoft Excel 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Powerpoint 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\powerpnt.exe"
objShortCut.Description = "Microsoft Powerpoint 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Access 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\msaccess.exe"
objShortCut.Description = "Microsoft Access 2003"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Outlook 2003.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office11\outlook.exe"
objShortCut.Description = "Microsoft Outlook 2003"
objShortCut.Save    

' * ** * ** * ** * ** * ** * ** * ** '* office 2010 链接起点 * ' * ** * ** * ** * ** * ** * ** * **

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _ 
    "\Microsoft Word 2010.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office14\winword.exe"
objShortCut.Description = "Microsoft Word 2010"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Excel 2010.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office14\excel.exe"
objShortCut.Description = "Microsoft Excel 2010"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Powerpoint 2010.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office14\powerpnt.exe"
objShortCut.Description = "Microsoft Powerpoint 2010"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Access 2010.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office14\msaccess.exe"
objShortCut.Description = "Microsoft Access 2010"
objShortCut.Save

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
    "\Microsoft Outlook 2010.lnk")
objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office14\outlook.exe"
objShortCut.Description = "Microsoft Outlook 2010"
objShortCut.Save

请帮忙

4

1 回答 1

0

检查是否存在 Office 2010 文件夹并根据检查结果创建图标。

Const Office2003 = "C:\Program Files\Microsoft Office\Office11"
Const Office2010 = "C:\Program Files\Microsoft Office\Office14"

Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")

If fso.FolderExists(Office2010) Then
  officePath = Office2010
Else
  officePath = Office2003
End If

strDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _ 
  "\Microsoft Word.lnk")
objShortCut.TargetPath = fso.BuildPath(officePath, "winword.exe")
objShortCut.Description = "Microsoft Word"
objShortCut.Save
于 2013-06-24T13:15:47.913 回答