Samuel
Samuel

Reputation: 6490

Is nsis !system call broken (when calling xcopy)?

I am working with the latest 3.0b2 release and noticed that calling xcopy via !system call does not work.

I have a xcopy call which works flawlessly when called manually via command line but silently fails when piping it through !system.

(Note: I need !system as this is a compile time operation that must succeed before I can package data)

Here is a sample nsi script

!system 'xcopy'
!error "just exit"

Calling xcopy should return some output about invalid argument count etc, but xcopy is entirely silent. If I replace it with robocopy I get some output.

The really odd thing: I fired up Process Monitor and watched on Process Start of a valid xcopy call, it was something like that:

xcopy "d:\tool\*.pdb" "d:\dest\"  /y /g /k /r /s /f

It copied everything. But then I ran the exact same line in nsis with !system and ProcMon displayed exactly the same Process start call. I diffed both parameter sets, same working directory, same command line but the call via !system did not proceed to copy files. Procmon even says that the second call had an exit code of 0.

It's everything cool except it does not copy files.

Upvotes: 1

Views: 255

Answers (1)

Anders
Anders

Reputation: 101569

This seems to be a bug in XCopy, it fails to do anything if there is no valid StdIn handle. This bug seems to exist in several Microsoft tools that use the undocumented ulib.dll library to handle its input/output.

This Wine commit claims that <= Win2003 requires a console handle but a anonymous pipe worked for me on WinXP.

The next NSIS version will provide a empty StdIn pipe to the child to work around this bug, in the meantime you can use:

!system 'xcopy < nul'

or

!system 'start /wait /min xcopy'

Upvotes: 1

Related Questions