I modified your script a bit
I used single quotes in the command line since with double quotes filename with spaces didn't work. I also pure the quote correctly outside the add and only in the path
I changed exec to passthru so it can pass deluge output to command line. I also tried to check for the returned result but deluge-console.exe seems to return always 0 no matter what. BTW it checks correctly for command line errors at least
I still have problems with special characters in the filenames, like ^ and &
EDIT: I don't know why, i just discovered that to put a single ^ you need to pass two ^^, so ^^ get converted to one ^
^.^
EDIT2: There's absolutely something very nasty going on in the way deluge processes path from command lines. '\' are converted into '\\' (why? you have to choose if accept escape characters or not, without staying in the middle) nad torrents doesn't start in deluge, it tells me that
"The filename, directory name, or volume label syntax is incorrect: Z:\\AAA\\BBB\\XXX\III\AAA.exe"
Note how the \\ and \ are mixed up
EDIT 3: It seems I was able to work all the issues around and repacked it. The torrent file is now copied over a temporary file before adding it, this should avoid all the unecessary filename "handling" of deluge-console.exe. Also \\ are turned into / and I used php function to extract the pathname