Skip to content
⌘ NSIS Forum Archive

Please help understand nsExec::Exec mystery

6 posts

nsnb#

Please help understand nsExec::Exec mystery

A baffling problem: The following line runs PERFECTLY in an NSIS script:
nsExec::Exec '"$varCOMSPEC" /C assoc .bat=batfile' 
But when adding redirection, it actually ruins the association:
nsExec::Exec '"$varCOMSPEC" /C assoc .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. 🙂
nsnb#
Originally posted by Afrow UK
In what way does it ruin the association?
It turns an OK context menu:

To this (incorrect) context menu:


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...
nsnb#
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?
Afrow UK#
It's more likely just how assoc.exe parses its command line. Command Prompt will give it everything before the > including the space.

Stu