home *** CD-ROM | disk | FTP | other *** search
- '''''''''''''''''''''''''''''''''''''''''
- '''''''''''''''''''''''''''''''''''''''''
- ' SharpDevelop Install Script
- ' Author: Brent R. Matzelle
- ' Date: 2002-02-07
- '''''''''''''''''''''''''''''''''''''''''
- Option Explicit
-
- Dim oShell
-
- ' Start main
- Call Main
-
- '************************************************
- ' Main sub-routine
- '************************************************
- Sub Main()
- Dim sOption, sInstallPath
-
- sInstallPath = ""
- sOption = ""
-
- Set oShell = WScript.CreateObject("WScript.Shell")
-
- If Wscript.Arguments.Count < 1 Then
- Call PrintUsage("Incorrect parameters")
- Exit Sub
- End If
-
- ' Get the type, install or uninstall command-line options
- sOption = Wscript.Arguments(0)
-
- Select Case sOption
- Case "-r"
- sInstallPath = Wscript.Arguments(1)
- Call RemoveEnvPath(sInstallPath)
-
- Case "-h"
- Call PrintUsage("")
-
- Case Else
- Wscript.Echo "You must provide the proper arguments"
- End Select
-
- End Sub
-
- '************************************************
- ' Removes the path from the registry
- '************************************************
- Sub RemoveEnvPath(ByVal strPath)
- On Error Resume Next
- Dim strKeyValue
-
- strKeyValue = oShell.RegRead("HKCU\Environment\path")
- strPath = ";" & strPath
-
- If Err.Number <> 0 Then
- HandleError Err.Description
- Exit Sub
- End If
-
- ' Remove the path
- strKeyValue = Replace(strKeyValue, strPath, "")
-
- oShell.RegWrite "HKCU\Environment\path", strKeyValue, "REG_SZ"
- If Err.Number <> 0 Then
- HandleError Err.Description
- Exit Sub
- End If
-
- End Sub
-
-
- '************************************************
- ' Handles errors
- '************************************************
- Sub HandleError(sMessage)
- ' Just print and return
- Wscript.Echo "An error has occurred: " & Err.Description
- End Sub
-
- '************************************************
- ' Prints out the normal program usage parameters
- '************************************************
- Sub PrintUsage(sMessage)
- Dim sUsage
-
- If Len(sMessage) > 0 Then
- sUsage = sMessage & Chr(10)
- End If
-
- sUsage = sUsage & "SharpDevelop Installer Script" & Chr(10) & "Usage: " & _
- "sharp-install.vbs [OPTIONS]" & Chr(10) & Chr(10) & _
- "Options:" & Chr(10) & _
- "-r [BIN_PATH] (remove)" & Chr(10) & _
- "-h (print help)" & Chr(10)
- Wscript.Echo sUsage
-
- End Sub