home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / sharpdevelop / 087cSetup.exe / sharp-install.vbs
Encoding:
Text File  |  2002-02-07  |  2.5 KB  |  99 lines

  1. '''''''''''''''''''''''''''''''''''''''''
  2. '''''''''''''''''''''''''''''''''''''''''
  3. ' SharpDevelop Install Script
  4. ' Author: Brent R. Matzelle
  5. ' Date: 2002-02-07
  6. '''''''''''''''''''''''''''''''''''''''''
  7. Option Explicit
  8.  
  9. Dim oShell
  10.  
  11. ' Start main
  12. Call Main
  13.  
  14. '************************************************
  15. ' Main sub-routine
  16. '************************************************
  17. Sub Main()
  18.     Dim sOption, sInstallPath
  19.     
  20.     sInstallPath = ""
  21.     sOption = ""
  22.     
  23.     Set oShell = WScript.CreateObject("WScript.Shell")
  24.  
  25.     If Wscript.Arguments.Count < 1 Then
  26.         Call PrintUsage("Incorrect parameters")
  27.         Exit Sub
  28.     End If
  29.     
  30.     ' Get the type, install or uninstall command-line options
  31.     sOption = Wscript.Arguments(0)
  32.  
  33.     Select Case sOption
  34.         Case "-r"
  35.             sInstallPath = Wscript.Arguments(1)
  36.             Call RemoveEnvPath(sInstallPath)
  37.         
  38.         Case "-h"
  39.             Call PrintUsage("")
  40.  
  41.         Case Else
  42.             Wscript.Echo "You must provide the proper arguments"
  43.     End Select
  44.     
  45. End Sub
  46.  
  47. '************************************************
  48. ' Removes the path from the registry
  49. '************************************************
  50. Sub RemoveEnvPath(ByVal strPath)
  51. On Error Resume Next
  52.     Dim strKeyValue
  53.  
  54.     strKeyValue = oShell.RegRead("HKCU\Environment\path")
  55.     strPath = ";" & strPath
  56.  
  57.     If Err.Number <> 0 Then
  58.         HandleError Err.Description
  59.         Exit Sub
  60.     End If
  61.  
  62.     ' Remove the path
  63.     strKeyValue = Replace(strKeyValue, strPath, "")
  64.     
  65.     oShell.RegWrite "HKCU\Environment\path", strKeyValue, "REG_SZ"
  66.     If Err.Number <> 0 Then
  67.         HandleError Err.Description
  68.         Exit Sub
  69.     End If
  70.  
  71. End Sub
  72.  
  73.  
  74. '************************************************
  75. ' Handles errors
  76. '************************************************
  77. Sub HandleError(sMessage)
  78.     ' Just print and return
  79.     Wscript.Echo "An error has occurred: " & Err.Description
  80. End Sub
  81.  
  82. '************************************************
  83. ' Prints out the normal program usage parameters
  84. '************************************************
  85. Sub PrintUsage(sMessage)
  86.     Dim sUsage
  87.     
  88.     If Len(sMessage) > 0 Then
  89.         sUsage = sMessage & Chr(10)
  90.     End If
  91.  
  92.     sUsage = sUsage & "SharpDevelop Installer Script" & Chr(10) & "Usage: " & _
  93.              "sharp-install.vbs [OPTIONS]" & Chr(10) & Chr(10) & _
  94.              "Options:" & Chr(10) & _
  95.              "-r [BIN_PATH] (remove)" & Chr(10) & _
  96.              "-h (print help)" & Chr(10)
  97.     Wscript.Echo sUsage
  98.     
  99. End Sub