[gptalk] Re: Shortcuts with Environment Variables

  • From: <dcnash@xxxxxxxxxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Thu, 4 Jan 2007 9:28:12 -0500

Well the problem is, the users dont have access rights to their desktop. So I 
would need it to launch the program instead of it making a shortcut for it.
> 
> From: Jeremy Saunders <jeremy.saunders@xxxxxxxxxxx>
> Date: 2007/01/04 Thu AM 06:57:04 EST
> To: gptalk@xxxxxxxxxxxxx
> Subject: [gptalk] Re: Shortcuts with Environment Variables
> 
> I agree. Here is one I created that will check to see which version of
> Office is installed simply by first checking the Office11 path and then
> create/modify  a shortcut on the Quick Launch bar. I did this a couple of
> years ago for a customer who was migrating from Office 2000 to Office 2003.
> 
> Watch for the line wrap.
> 
> ---------------------------------Start of
> script-------------------------------------
> 'Initialization Section
> 
> Option Explicit
> Dim fso, wshShell, QuickLaunchToolbar, ApplicationPath, QuickLaunchShortcut
> Dim strAUPrograms, strSystemRoot, strAUStartup, strAUDesktop, strPrograms
> Set WshShell = WScript.CreateObject("WScript.Shell")
> set fso = CreateObject("Scripting.FileSystemObject")
> strPrograms = WshShell.ExpandEnvironmentStrings("%ProgramFiles%")
> strSystemRoot = WshShell.ExpandEnvironmentStrings("%systemroot%")
> strAUPrograms = WshShell.SpecialFolders("AllUsersPrograms")
> strAUStartup = WshShell.SpecialFolders("AllUsersStartup")
> strAUDesktop = WshShell.SpecialFolders("AllUsersDesktop")
> 
> 'Main Processing Section
> 
> ModifyQuickLaunchToolbar()
> WScript.Quit()
> 
> 'Procedure Section
> 
> 'Add application shortcuts to the Quick Launch Toolbar
> Sub ModifyQuickLaunchToolbar()
> 
>   QuickLaunchToolbar = WshShell.SpecialFolders("AppData")
>   ApplicationPath = QuickLaunchToolbar & "\Microsoft\Internet
> Explorer\Quick Launch"
> 
>   If NOT fso.FolderExists(QuickLaunchToolbar & "\Microsoft") Then
>     fso.CreateFolder(QuickLaunchToolbar & "\Microsoft")
>   End If
> 
>   If NOT fso.FolderExists(QuickLaunchToolbar & "\Microsoft\Internet
> Explorer") Then
>     fso.CreateFolder(QuickLaunchToolbar & "\Microsoft\Internet Explorer")
>   End If
> 
>   If NOT fso.FolderExists(QuickLaunchToolbar & "\Microsoft\Internet
> Explorer\Quick Launch") Then
>     fso.CreateFolder(QuickLaunchToolbar & "\Microsoft\Internet
> Explorer\Quick Launch")
>   End If
> 
>   If fso.FileExists(strPrograms & "\Microsoft Office\Office11\Winword.exe")
> Then
>     Set QuickLaunchShortcut = WshShell.CreateShortcut(ApplicationPath &
> "\Microsoft Word.lnk")
>     QuickLaunchShortcut.TargetPath = strPrograms & "\Microsoft
> Office\Office11\Winword.exe"
>     QuickLaunchShortcut.Save
>   Else
>     Set QuickLaunchShortcut = WshShell.CreateShortcut(ApplicationPath &
> "\Microsoft Word.lnk")
>     QuickLaunchShortcut.TargetPath = strPrograms & "\Microsoft
> Office\Office\Winword.exe"
>     QuickLaunchShortcut.Save
>   End If
> 
>   If fso.FileExists(strPrograms & "\Microsoft Office\Office11\Winword.exe")
> Then
>     Set QuickLaunchShortcut = WshShell.CreateShortcut(ApplicationPath &
> "\Microsoft Excel.lnk")
>     QuickLaunchShortcut.TargetPath = strPrograms & "\Microsoft
> Office\Office11\Excel.exe"
>     QuickLaunchShortcut.Save
>   Else
>     Set QuickLaunchShortcut = WshShell.CreateShortcut(ApplicationPath &
> "\Microsoft Excel.lnk")
>     QuickLaunchShortcut.TargetPath = strPrograms & "\Microsoft
> Office\Office\Excel.exe"
>     QuickLaunchShortcut.Save
>   End If
> 
> End Sub
> ---------------------------------End of
> script-------------------------------------
> 
> Cheers.
> 
>  Kind regards,
> 
>  Jeremy Saunders
>  Senior Technical Specialist
> 
>  Infrastructure Technology Services
>  (ITS) & Cerulean
>  Global Technology Services (GTS)
>  IBM Australia
>  Level 1, 1060 Hay Street
>  West Perth  WA  6005
> 
>  Postal: PO Box 525, West Perth WA
>  6872
> 
>  Visit us at
>  http://www.ibm.com/services/au/its
> 
>  P:  +61 8 9261 8412                F:  +61 8 9261 8486
>  P:  (Reception) +61 8 9261 8420    E-mail:
>  M:  TBA                            jeremy.saunders@xxxxxxxxxxx
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>                                                                        
>              "Darren Mar-Elia"                                         
>              <darren@xxxxxxxxx                                         
>              m>                                                         To
>              Sent by:                  <gptalk@xxxxxxxxxxxxx>          
>              gptalk-bounce@fre                                          cc
>              elists.org                                                
>                                                                    Subject
>                                        [gptalk] Re: Shortcuts with     
>              04/01/2007 02:05          Environment Variables           
>              AM                                                        
>                                                                        
>                                                                        
>              Please respond to                                         
>              gptalk@freelists.                                         
>                     org                                                
>                                                                        
>                                                                        
> 
> 
> 
> 
> DC-
> You probably need to create the shortcut on the fly using WSH if you really
> want this to work. There's probably several ways you could skin this. First
> off, Windows keeps paths to various installed executables in the registry
> under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
> Paths\, so you could query this for Excel.exe to find the definitive path
> to
> Excel without having to mess with Environment variables. You could probably
> do that using reg.exe in a batch file. Alternatively, you can certainly
> expand environment variables in VBScript and create shortcuts on the fly as
> well. You might want to check out these samples on the TechNet Scripting
> Center:
> 
> http://www.microsoft.com/technet/scriptcenter/scripts/desktop/explorer/dmexv
> 
> b04.mspx
> http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_aytf.mspx?mfr=tr
> 
> ue
> 
> Darren
> 
> 
> Darren Mar-Elia
> CTO & Founder
> SDM Software, Inc.
> www.sdmsoftware.com
> darren@xxxxxxxxxxxxxxx
> 
> Speed Group Policy Troubleshooting with the NEW GPHealth Reporter tool at
> http://www.sdmsoftware.com/products.php
> 
> 
> 
> -----Original Message-----
> From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
> Behalf Of dcnash@xxxxxxxxxxxxx
> Sent: Wednesday, January 03, 2007 8:11 AM
> To: gptalk@xxxxxxxxxxxxx
> Subject: [gptalk] Shortcuts with Environment Variables
> 
> Here is my situation, we have close to 150 computers, some with different
> versions of office on them. We have some systems with Office XP installed
> and some with Office 2003. They all run Windows XP. As you know office's
> installation path for Office XP is c:\program files\microsoft
> office\office10. The only difference between the installation path for XP
> and 2003 is c:\*\office11 instead of c:\*\office10.
> I'm trying to create a shortcut that points to excel.exe within the default
> installation path for office. There is only one version of office installed
> on each system therefore only ONE of these folders will exist.
> So far Ive created an environment variable that points to c:\program
> files\microsoft office\office*\. Ive named the environment variable Office.
> When I open command prompt and type "cd %office%" it works beautifully.
> When
> I create the shortcut it tries to resolve the folder path litterally as
> "c:\%office%\excel.exe" instead of substituting the environment variable
> value of "c:\program files\microsoft office\office*\"
> 
> I can create a batch file that runs it, copy that via login script to local
> boxes, then create and run a shortcut that points to the batch file and
> hides the command prompt window, but that would be a major pain in the
> behind. Any ideas here? Im wondering if there is a vbscript or something
> that will actually run the program for me from the correct folder path. I
> dont know vbscript otherwise I would try and write this myself. Any help is
> greatly appreciated!
> 
> Thanks guys!
> 
> DC Nash
> 
> ***********************
> You can unsubscribe from gptalk by sending email to
> gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by
> logging into the freelists.org Web interface. Archives for the list are
> available at http://www.freelists.org/archives/gptalk/
> ************************
> 
> ***********************
> You can unsubscribe from gptalk by sending email to
> gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by
> logging into the freelists.org Web interface. Archives for the list are
> available at http://www.freelists.org/archives/gptalk/
> ************************
> 
> 
> ***********************
> You can unsubscribe from gptalk by sending email to 
> gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by 
> logging into the freelists.org Web interface. Archives for the list are 
> available at http://www.freelists.org/archives/gptalk/
> ************************
> 

***********************
You can unsubscribe from gptalk by sending email to 
gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by 
logging into the freelists.org Web interface. Archives for the list are 
available at http://www.freelists.org/archives/gptalk/
************************

Other related posts: