Ooops, my bad. I mis-read and thought you were deleting all records.

The alternative method is then not to increment the counter if you are deleting a record:
 Code:
If NOT @LOGONMODE
	Break On
Else
	Break Off
EndIf
Dim $RC
$RC=SetOption("Explicit", "On")
$RC=SetOption("NoMacrosInStrings", "On")
$RC=SetOption("NoVarsInStrings", "On")
$RC=SetOption("WrapAtEOL", "On")
 
Dim $Ptr, $index, $OldServer
$index = 0
$OldServer = "OldServer"
 
$Ptr = EnumKey("HKCU\Printers\Connections\",$index)
While NOT @ERROR
	If InStr($Ptr,$OldServer)
		$RC = DelKey("HKCU\Printers\Connections\" + $Ptr + "\")
	Else
		$index = $index + 1
	EndIf
	$Ptr = EnumKey("HKCU\Printers\Connections\",$index)
Loop