Dim WSHShell,strRegKey
Set WSHShell = CreateObject("WScript.Shell")
strRegKey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path"
If KeyExists(strRegKey) = True Then
SITE = WSHShell.RegRead(strRegKey)
Result = Replace(SITE, ";;", ";")
FirstChar = Left(Result,1)
LastChar = Right(Result,1)
If FirstChar = ";" Then
LeftoverFirstChar = Mid(Result,2)
Result = LeftoverFirstChar
End If
Count = Len(Result) -1
If LastChar = ";" Then
LeftoverLastChar = Left(Result,count)
Result = LeftoverLastChar
End If
'wscript.echo FirstChar
'wscript.echo LastChar
'wscript.echo LeftoverFirstChar
'Wscript.echo LeftoverLastChar
'wscript.echo Result
WSHShell.Regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path",Result,"REG_EXPAND_SZ"
Else
End If
Function KeyExists (strRegKey)
Dim key2
On Error Resume Next
key2 = WSHShell.RegRead (strRegKey)
If err <> 0 Then
KeyExists = False
Else
KeyExists = True
End if
End Function
Comments