Solved

Desktop Icon GPO

Posted on 2012-03-30
4
894 Views
Last Modified: 2012-04-17
Hi Experts,

I am currently using the below script to deploy desktop icons to a mixture of PCs at my clients school via GPO. The server is 2008 and the PCs are winxp and win7. The winxp are using office 2003 and the win7 are using office2010. The issue i have is that the below script cannot tell the difference between office11 and office14 in the regsitry settings, can anyone help me alter the script to be able to do that?

'MS Word
Set WSHShellMSW = WScript.CreateObject("WScript.Shell")
'Dim MyShortcut, MyDesktop, DesktopPath
'DesktopPath = WSHShell.SpecialFolders("Desktop")
sUsersProfileMSW = WshShellMSW.ExpandEnvironmentStrings("%USERPROFILE%")
Set MyShortcutMSW = WSHShellMSW.CreateShortcut(sUsersProfileMSW & "\desktop\MicrosoftWord.lnk")
MyShortcutMSW.TargetPath = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office14\WINWORD.exe")
MyShortcutMSW.WorkingDirectory = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office14\")
MyShortcutMSW.WindowStyle = 4
MyShortcutMSW.IconLocation = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office14\WINWORD.exe, 0")
MyShortcutMSW.Save
0
Comment
Question by:ncomper
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
HaiFai earned 500 total points
ID: 37786568
Hi

This probably does what you want

'MS Word
Set WSHShellMSW = WScript.CreateObject("WScript.Shell")
set fs=CreateObject("Scripting.FileSystemObject")
'Dim MyShortcut, MyDesktop, DesktopPath
'DesktopPath = WSHShell.SpecialFolders("Desktop")
sUsersProfileMSW = WshShellMSW.ExpandEnvironmentStrings("%USERPROFILE%")
Set MyShortcutMSW = WSHShellMSW.CreateShortcut(sUsersProfileMSW & "\desktop\MicrosoftWord.lnk")

'32 bit office 2010 in 32bit system 
If fs.FolderExists("C:\Program Files\Microsoft Office\Office14") Then
MyShortcutMSW.TargetPath = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office14\WINWORD.exe")
MyShortcutMSW.WorkingDirectory = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office14\")
MyShortcutMSW.WindowStyle = 4
MyShortcutMSW.IconLocation = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office14\WINWORD.exe, 0")
MyShortcutMSW.Save
End If

'32 bit office 2010 in 64bit system 
If fs.FolderExists("C:\Program Files (x86)\Microsoft Office\Office14") Then
MyShortcutMSW.TargetPath = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.exe")
MyShortcutMSW.WorkingDirectory = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files (x86)\Microsoft Office\Office14\")
MyShortcutMSW.WindowStyle = 4
MyShortcutMSW.IconLocation = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.exe, 0")
MyShortcutMSW.Save
End If

'32 bit office 2003 in 32bit system 
If fs.FolderExists("C:\Program Files\Microsoft Office\Office11") Then
MyShortcutMSW.TargetPath = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office11\WINWORD.exe")
MyShortcutMSW.WorkingDirectory = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office11\")
MyShortcutMSW.WindowStyle = 4
MyShortcutMSW.IconLocation = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files\Microsoft Office\Office11\WINWORD.exe, 0")
MyShortcutMSW.Save
End If

'32 bit office 2003 in 64bit system 
If fs.FolderExists("C:\Program Files (x86)\Microsoft Office\Office11") Then
MyShortcutMSW.TargetPath = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files (x86)\Microsoft Office\Office11\WINWORD.exe")
MyShortcutMSW.WorkingDirectory = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files (x86)\Microsoft Office\Office11\")
MyShortcutMSW.WindowStyle = 4
MyShortcutMSW.IconLocation = WSHShellMSW.ExpandEnvironmentStrings("C:\Program Files (x86)\Microsoft Office\Office11\WINWORD.exe, 0")
MyShortcutMSW.Save
End If

Open in new window

0
 
LVL 5

Author Comment

by:ncomper
ID: 37786584
Perfect thanks for your prompt reply, i will put it to the test and confirm shortly.
0
 
LVL 5

Author Comment

by:ncomper
ID: 37855761
Hi,

Thanks for the above, that works perfectly. I am looking to put other desktop icons in the script too, Excel, PowerPoint and Access. How easy would this be to implement, will i need to match the above for every separate MS Office icon?
0
 
LVL 5

Author Closing Comment

by:ncomper
ID: 37855930
I have managed to replicate the same to all icons and have got Word, Excel, PowerPoint, Access, Publisher and Picture Manager working.

Thank you for you help, saved me a real headache.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now