Archive: Please help understand nsExec::Exec mystery


Please help understand nsExec::Exec mystery
A baffling problem: The following line runs PERFECTLY in an NSIS script:

nsExec::Exec'"$varCOMSPEC"/Cassoc.bat=batfile'

But when adding redirection, it actually ruins the association:
nsExec::Exec'"$varCOMSPEC"/Cassoc.bat=batfile>nsExecTest.log'

Any idea why?

Please note that I am not asking about the 'assoc' internal Windows command (I also know about the alternative File Association plugin). I am merely trying to understand why the behavioral change of nsExec::Exec when adding redirection to a log file.

Thanks. :)

In what way does it ruin the association?

Stu


Originally posted by Afrow UK
In what way does it ruin the association?
It turns an OK context menu:
http://img190.imageshack.us/img190/6439/assocok.th.png
To this (incorrect) context menu:
http://img182.imageshack.us/img182/1913/assocbad.th.png

I also compared the registry before and after and the only relevant difference that I was able to spot is:

OK:
[HKEY_CLASSES_ROOT\.bat]
@="batfile"
BAD:
[HKEY_CLASSES_ROOT\.bat]
@="batfile "
Apparently the redirection appends a space after "batfile". Hmmm...

Try getting rid of the space before the >.

Stu


Originally posted by Afrow UK
Try getting rid of the space before the >.
Thank you! That helped.

It turns out that this problem exists in the command.com prompt (in Windows XP at least) without regard to NSIS.

The following works:
"%COMSPEC%" /C assoc .bat=batfile> nsExecTest.log
While the following doesn't work:
"%COMSPEC%" /C assoc .bat=batfile > nsExecTest.log
Is this considered a bug in command.com?

It's more likely just how assoc.exe parses its command line. Command Prompt will give it everything before the > including the space.

Stu