'==========================================================================
' Set environment Path
' written and (c) 2004 by Wolfgang Zerzawy (zacky)
' This tool is freeware (donationware)
' but please notify me if you find it useful - webmaster(at)zacky.de
' DATE : 30.09.2004
'use xxx.vbs to insert path at the beginning
'use xxx.vbs /u to remove path
'==========================================================================
'Schaltet Überprüfung auf deklaration aller verwendeter Variablen ein
Option Explicit
'Errorhandler umleiten, damits nicht haengenbleibt
'On Error Resume Next
Dim argCount,instmode
instmode = "install"
argCount = Wscript.Arguments.Count
If argCount > 0 Then
If InStr(1, Wscript.Arguments(0), "u", vbTextCompare) > 0
Then
instmode = "uninstall"
End If
End If
'"Objekt"variablen deklarieren
Dim WSHShell,WshSysEnv
'Pfadvariablen deklarieren
Dim strPath,NewPath
'Objekte referenzieren auf Variablen
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
'Einlesen des aktuellen Sys-Environments (HKLM) in Variable
strPath = (WshSysEnv("PATH"))
'Variable ergänzen
newPath = "C:\Program Files\JavaSoft\JRE\1.3.1_02\bin;"
dim ret : ret = InStr (1,strPath , NewPath ,1)
If instmode = "uninstall" Then
'uninstal
If ret <> 0 Then
strPath = Replace (strPath,NewPath,"")
WshSysEnv("PATH") = strPath
Else
WScript.Quit(1)
End If
Else
'install
If ret <> 0 Then
WScript.Quit(1)
Else
strPath = NewPath & strPath
WshSysEnv("PATH") = strPath
End If
End If
WScript.Quit (0)
'======================= END
================================