Solved

script to copy microsoft office shortcuts to desktop

Posted on 2014-01-31
6
2,046 Views
Last Modified: 2015-01-15
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
Comment
Question by:Anthony H.
6 Comments
 
LVL 20

Expert Comment

by:ltlbearand3
ID: 39827147
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
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 39827280
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
 

Author Comment

by:Anthony H.
ID: 39831453
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 39831554
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
 

Expert Comment

by:CPTholen
ID: 40552257
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
 

Author Comment

by:Anthony H.
ID: 40552639
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

821 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