From Chartreuse Panda, 5 Years ago, written in Visual Basic.
Embed
  1. Quick Start for Install Audacity.vbs file
  2.  
  3. 1. Download the zipped version of Audacity,
  4.    and unzip to a share on your server
  5.  
  6. 2. Edit the 'Install Audacity.vbs' file,
  7.    and change the 'strSrcPath' variable to
  8.    the UNC path you just created
  9.  
  10. 3. Create a GPO which adds 'Install Audacity.vbs'
  11.    to the setting 'Computer Configuration' ->
  12.    'Windows Settings' -> 'Scripts (Startup/shutdown)'
  13.    Add a script parameter of '/f' to force installation
  14.  
  15. 4. Apply the GPO to the OU of your choice
  16.  
  17.  
  18. Quick Start & installation script written by Rick Bull
  19. <http://www.rickbull.com/> (2007-04-14, updated 2008-03-31);
  20. please report any problems/suggestions/comments to me.
  21.  
  22. Many thanks to Audacity <http://audacity.sourceforge.net/>
  23. for some great free software!
  24.  
  25. 'V1.1 (2009-03-31)
  26. 'Copies the contents of 'Audacity' to the program files,
  27. 'and creates a shortcut on the desktop.
  28. 'Optional Parameters:
  29. ' /f    - Forces installation of Audacity regardless of previous installations
  30.  
  31. 'Written by Rick Bull 2007-04-14 (http://www.rickbull.com/)
  32. 'Updated 2009-03-31 to include force installation option; unified variable naming style
  33. 'Please feel free to e-mail me questions or just a quick thanks!
  34.  
  35.  
  36. 'VARIABLE/CONST DECLARATIONS: -----------------------------
  37.  
  38. 'EDIT THESE VARIABLES:
  39. Dim strDestPath, strSrcPath, strWorking
  40. Dim bolIconMenu, bolIconDesktop
  41. strDestPath = GetPFPath & "\Audacity"   'Destination of program files
  42. strSrcPath = "\\SERVER\Share$\Audacity" 'Source of Audacity files
  43. strWorking = "Z:"                       'Working directory of shortcuts
  44. bolIconMenu = TRUE                      'Create Start Menu icon?
  45. bolIconDesktop = TRUE                   'Create Desktop icon?
  46.  
  47.  
  48.  
  49. 'Create the WSH objects for use
  50. Set objShell = WScript.CreateObject("WScript.Shell")
  51. Set objFSO = CreateObject("Scripting.FileSystemObject")
  52.  
  53.  
  54.  
  55.  
  56. 'FUNCTIONS/SUBS: -----------------------------
  57.  
  58. 'Creates a shortcut to Audacity in the specified location
  59. Sub AudacityShortcut(Path)
  60.   Set objShortcut =   objShell.CreateShortcut(Path & "\Audacity.lnk")
  61.   objShortcut.TargetPath = strDestPath & "\audacity.exe"
  62.   objShortcut.WorkingDirectory = "Z:"
  63.   objShortcut.Save
  64. End Sub
  65.  
  66. 'Returns TRUE if we should install Audacity (i.e. if the "/f" param has been passed in OR the application folder doesn't already exist)
  67. Function AllowInstall
  68.         'Loop through all arguments passed in (if they exist)
  69.         Dim intArgIndex
  70.         If WScript.Arguments.Count > 0 Then
  71.                 For intArgIndex = 0 to WScript.Arguments.Count - 1
  72.                         'If this argument = "/f"
  73.                         If LCase (WScript.Arguments(intArgIndex)) = "/f" Then
  74.                                 'Set force install variable to TRUE and exit loop
  75.                                 AllowInstall = TRUE
  76.                                 Exit Function
  77.                         End If
  78.                 Next
  79.         End If
  80.  
  81.         'If we've got here "/f" isn't present, so return TRUE only if the destination folder doesn't exist
  82.         AllowInstall = Not objFSO.FolderExists(strDestPath)
  83. End Function
  84.  
  85.  
  86.  
  87.  
  88. 'MAIN SCRIPT: -----------------------------
  89.  
  90. 'Only execute if the files do no already exist
  91. If AllowInstall() Then
  92.  
  93.   'Gets the path of "Program Files"
  94.   'Adapted from Réal Gagnon's code found at
  95.   'http://www.rgagnon.com/wshdetails/wsh-0025.html
  96.   Function GetPFPath
  97.     Set objShell = CreateObject("WScript.Shell")
  98.     Set objProcEnv = objShell.Environment("PROCESS")
  99.  
  100.     'Variable for return value
  101.     Dim strProgramFiles
  102.  
  103.     'Check the environment variable first
  104.     strProgramFiles = objProcEnv("ProgramFiles")
  105.  
  106.     'If it doesn't exist, query the registry
  107.     If strProgramFiles = "" Then
  108.       strProgramFiles = oShell.RegRead _
  109.        ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir")
  110.     End If
  111.  
  112.     'If still not found, just use the default location ("C:\Program Files")
  113.     If strProgramFiles = "" Then
  114.       strProgramFiles = "C:\Program Files"
  115.     End If
  116.  
  117.     'Return the value
  118.     GetPFPath = strProgramFiles
  119.   End Function
  120.  
  121.  
  122.  
  123.   'Copy the contents of "Audacity" to "Program Files"
  124.   objFSO.CopyFolder strSrcPath, strDestPath, TRUE
  125.  
  126.  
  127.   'Create a shortcut to the program on the Desktop & Start menu (all users)
  128.   If bolIconDesktop Then AudacityShortcut(objShell.SpecialFolders("AllUsersDesktop"))
  129.   If bolIconMenu Then AudacityShortcut(objShell.SpecialFolders("AllUsersPrograms"))
  130.  
  131. End If
  132.