KGen/Sanity would have caught that for ya.. Here's the output from KGen using your script as a source:
 Code:
G0PW01 - C:\temp\x>kgen x

KGen v2.4 - Kixtart script UDF linker
(C) 2000-2009 - Glenn Barnas / Inno-Tech Consulting

Searching for available UDFs........................
 194 UDFs located in 121 files.
No UDFs needed for this generation!
Generation of x.KIX is complete!

Pass 1 : 33
Pass 2.

Warning: Undeclared variable.
              Variable Name: $OldSrv
                In function: Main
         Referenced on line: 3

Warning: Undeclared variable.
              Variable Name: $aDCPtrs
                In function: Main
         Referenced on line: 6

Warning: Undeclared variable.
              Variable Name: $defaultprn
                In function: Main
         Referenced on line: 10

Warning: Undeclared variable.
              Variable Name: $Ptr
                In function: Main
         Referenced on line: 12

Warning: Undeclared variable.
              Variable Name: $NewSrv
                In function: Main
         Referenced on line: 17

Warning: Possible mismatched parenthesis.
                In function: GetDefaultPrinter
         Referenced on line: 27
         PF=3
     27: $GetDefaultPrinter = Join(Split(ReadValue("HKEY_USERS\" + @sid +

Warning: Possible mismatched parenthesis.
                In function: GetDefaultPrinter
         Referenced on line: 28
         PF=-1
     28: "\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device"),

Warning: Possible mismatched parenthesis.
                In function: GetDefaultPrinter
         Referenced on line: 29
         PF=-2
     29: ',', 1), '')
Pass 3 : 33
Pass 4..
Pass 5 : 32
Warning: 1 Unterminated For statement(s)!
 8 warnings generated, 33 lines processed.
And here's the CodeMap file:
 Code:
000001: Main
000011:  For Each $Ptr in $aDCPtrs
000013:   if "$defaultprn"="$OldSrv""$Pt
000016:    if SetDefaultPrinter("$NewSrv"
000018:    EndIf
000019:   EndIf

000025: Function: GetDefaultPrinter
 - Warning: Open For when defining function. 1
000029: EndFunction GetDefaultPrinter
Warning: 1 Unterminated For statement(s)!
The CodeMap file makes it easy to see missing function pairs.

KGen with Sanity is part of our KixDev product, which is free to download from our web site.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D