You'll need nsh.zip and extract it in your plugins directory of NSIS.

A top of your NSIS script put this line of code :

CODE:
  1. #Custom Macros
  2. !insertmacro GetDrives

Put following function in your code :

CODE:
  1. /**
  2. * Each time an existing drive is found (${GetDrives}, this function is called
  3. */
  4. Function DriveFound
  5. StrCpy $9 $9 1 #Take first character and store it in variable 9
  6. ${StrReplace} $7 $9 "" $7 #In the string with all drives we replace the found drive by an empty string
  7. Push $0 #Search for next drive
  8. FunctionEnd

Now you can get the first unused drive lettter of the alphabet like this :

CODE:
  1. StrCpy $7 "CDEFGHIJKLMNOPQRSTUVWXYZ"
  2. ${GetDrives} "ALL" "DriveFound" #Search for all existing Drives
  3. StrCpy $7 $7 1 #Take first of free drive-letters.

That's it.

More info at http://nsis.sourceforge.net/GetDrives