Hey Peter,
You can read values from the registry using Microsoft's "reg.exe" tool (included in all versions of Windows NT -- 2000, XP, Vista, 7, etc., etc.).
Here are 2 help documents I found after a few minutes of googling:
You can use "Reg query" in a batch file to read the database details from the registry, store them in a variable, then pass them to "slqcmd".
Tell me if this helps.