Welcome! There's plenty of talent here to give you a good nudge (or shove) in the right direction!

"End" isn't valid - use Exit 0, or wrap the entire process in a positive logic If statement -
 Code:
If KeyExist('HKEY_CURRENT_USER\SOFTWARE\Citrix')
  ; do your thing
EndIf
Exit 0
Your statement was "if exist", which checks for files.. change it as shown so it looks for a reg key.

Your other logic is missing EndIf statements, add those and you should be ok.
 Code:
If KeyExist('HKEY_CURRENT_USER\SOFTWARE\Citrix')
  ; do your thing
  If KeyExist("HKEY_CURRENT_USER\SOFTWARE\Citrix\Program Neighborhood Agent\Config URL")
    ; Delete Key
    $Rv = DelValue("HKEY_CURRENT_USER\SOFTWARE\Citrix\Program Neighborhood Agent", "Config URL")
  Else
    AddKey("HKEY_CURRENT_USER\SOFTWARE\Citrix\Program Neighborhood Agent\Config URL")
    $Rv = WriteValue("HKEY_CURRENT_USER\SOFTWARE\Citrix\Program Neighborhood Agent\Config URL","Enabled",
    "http://xxx.xxx.xxx.xxx/Citrix/PNAgent/config.xml", "REG_SZ")
  EndIf

  ; now do  your other thing... you get the idea!

EndIf
Exit 0

Also - be sure to use the $Rv = xxxx to capture the return values, or your screen will be littered with zeros (and possibly other numbers, which are error codes!) Any variable name is OK, but RC or RV are commonly used here to capture and discard the return values (RV) or return codes (RC) depending on what you call them.

Glenn

PS - wrap your code in [ CODE] code tags [ /code ] (without the spaces) to preserve your formatting.
_________________________
Actually I am a Rocket Scientist! \:D