Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Desktop Icon GPO

Posted on 2012-03-30
4
Medium Priority
?
906 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A safe way to clean winsxs folder from your windows server 2008 R2 editions
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

885 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