• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2375
  • Last Modified:

script to copy microsoft office shortcuts to desktop

I'm looking for a script that will copy Microsoft office 2010 AND 2013 application shortcuts to users' desktops.

can any one help me find this? or help me create it?
for windows 7 pro computers running 64 bit.


similar to this (VBS file):
Const Office2003 = "C:\Program Files (x86)\Microsoft Office\Office11"
Const Office2010 = "C:\Program Files (x86)\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
0
Anthony H.
Asked:
Anthony H.
1 Solution
 
ltlbearand3Commented:
I guess I don't really understand what you need.  You have all the logic you need in your script.  You just need to make some tweaks and put in a little extra code.  You will need to get the path for Office 2013.

For example just break out the two sections of code to copy each version of office.  Then you just need to copy and add the code for each MS office program that needs a shortcut.

Something like this:
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")


' Office 2010
Const Office2010 = "C:\Program Files (x86)\Microsoft Office\Office14"

If fso.FolderExists(Office2010) Then
  officePath = Office2010

	strDesktopFolder = objShell.SpecialFolders("Desktop")

	' Create MS Word Shortcut
	Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
		"\Microsoft Word.lnk")
	objShortCut.TargetPath = fso.BuildPath(officePath, "winword.exe")
	objShortCut.Description = "Microsoft Word"
	objShortCut.Save 
	
	' Create MS Word Shortcut
	Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
		"\Microsoft Word.lnk")
	objShortCut.TargetPath = fso.BuildPath(officePath, "Excel.exe")
	objShortCut.Description = "Excel"
	objShortCut.Save 

	' And So ON for each product

End If


' Now just repeat the If statement code with values for Office 2013

Open in new window

0
 
Robberbaron (robr)Commented:
this works for my system with 2007 installed.
dim fso, objShell
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")


'MakeOff "2007" , "C:\Program Files (x86)\Microsoft Office\Office12"
MakeOff "2010" , "C:\Program Files (x86)\Microsoft Office\Office14"
MakeOff "2013" , "C:\Program Files (x86)\Microsoft Office\Office15" 

Wscript.quit

Sub MakeOff(officeYear , officePath )

	If fso.FolderExists(officePath ) Then

		strDesktopFolder = objShell.SpecialFolders("Desktop")

		' Create MS Word Shortcut
		Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
			"\Word" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "winword.exe")
		
		objShortCut.Description = "Word" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 
		
		' Create MS Word Shortcut
		Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
			"\Excel" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "Excel.exe")
		objShortCut.Description = "Excel" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 

		' Create Shortcut
		Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
			"\Powerpoint" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "POWERPNT.EXE")
		objShortCut.Description = "PowerPoint" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 

		' Create Shortcut
		Set objShortCut = objShell.CreateShortcut(strDesktopFolder & _
			"\Outlook" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "OutLook.EXE")
		objShortCut.Description = "Outlook" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 


	End If

end sub

Open in new window


save as vbs file
0
 
Anthony H.Author Commented:
Robberbaron,

this is great. it works!  Could you please add the option to copy to "taskbar" and "start menu"?

like when I right click on a program and gives me the option to "Pin to taskbar" and "Pin to Start Menu".
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Robberbaron (robr)Commented:
they are "extra-specialfolders" i believe.  And maybe Win7+ only.

the std specialfolders are from http://technet.microsoft.com/en-us/library/ee156616.aspx

the pinned startmenu items are actually stored in the user profile under Internet Explorer....
C:\Users\Robber\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu
C:\Users\Robber\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

		strDesktopFolder = objShell.SpecialFolders("AppData")
		wscript.echo strDesktopFolder

Open in new window

points to roaming on vista+

so an update that should work (as i havent tested)
dim fso, objShell
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")


'MakeOff "2007" , "C:\Program Files (x86)\Microsoft Office\Office12"
MakeOff "2010" , "C:\Program Files (x86)\Microsoft Office\Office14"
MakeOff "2013" , "C:\Program Files (x86)\Microsoft Office\Office15" 

Wscript.quit

Sub MakeOff(officeYear , officePath )

	If fso.FolderExists(officePath ) Then

		strDesktopFolder = objShell.SpecialFolders("Desktop")
    CreateAllLinks strDesktopFolder

    strStartPin = objShell.SpecialFolders("AppData") & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu"
    CreateAllLinks strStartPin
    
    strTaskPin = objShell.SpecialFolders("AppData") & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\Taskbar"
    CreateAllLinks strTaskPin    
	End If

end sub

Sub CreateAllLinks(location)

		' Create MS Word Shortcut
		Set objShortCut = objShell.CreateShortcut(location & _
			"\Word" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "winword.exe")
		
		objShortCut.Description = "Word" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 
		
		' Create MS Word Shortcut
		Set objShortCut = objShell.CreateShortcut(location & _
			"\Excel" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "Excel.exe")
		objShortCut.Description = "Excel" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 

		' Create Shortcut
		Set objShortCut = objShell.CreateShortcut(location & _
			"\Powerpoint" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "POWERPNT.EXE")
		objShortCut.Description = "PowerPoint" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 

		' Create Shortcut
		Set objShortCut = objShell.CreateShortcut(location & _
			"\Outlook" & officeYear & ".lnk")
		objShortCut.TargetPath = fso.BuildPath(officePath, "OutLook.EXE")
		objShortCut.Description = "Outlook" & officeYear
		if fso.FileExists(objShortCut.TargetPath) then objShortCut.Save 

End SUb

Open in new window

0
 
CPTholenCommented:
I have created shortcuts vbs files for 32 bit and 64 bit windows  and all different versions. Is it possible for someone smart to make it all into one .vbs file which only puts icons for the app and architecture they have?
Office-Shortcuts.zip
0
 
Anthony H.Author Commented:
wow you're awesome. that's pretty cool. it worked!!  It didn't work at first but I think that's because I have office365 subscription, but I changed the path to where the EXE's are and it worked flawlessly. beautiful! thanks!!!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now