Solved

script to copy microsoft office shortcuts to desktop

Posted on 2014-01-31
6
1,845 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
Comment Utility
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
Comment Utility
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.
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 32

Expert Comment

by:Robberbaron (robr)
Comment Utility
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
Comment Utility
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.
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

7 Experts available now in Live!

Get 1:1 Help Now