Archive: !system call during compile time


!system call during compile time
Hi All,

I am making a !system call during compile time to start a batch file. In this batch file I have 2 commands, the first synchronises the source directory agains a given release using a tool called directory compare. this part works perfect. the sekond step is to copy in any customer specific files using xcopy and this command gets ignored. if i open a command shell in windows and call the batch file all works great. if i call it from nsis the xcopy command does not seem to execute (even though the interpreter says it is executing it).

please help

tia
patrick


how do you call it?

As xcopy is an internal command of cmd you need to start cmd and give the xcopy as a parameter

Maybe you can share your code


code
Hi,

actually I do not call xcopy directly, I call the following batch file, which in turn calls xcopy. xcopy is cmd internal? I have it laying under: C:\WINDOWS\SYSTEM32\xcopy.exe

NSIS call:

!system '..\common\scripte\copyRelease.bat'

oder:

!system 'cmd /c ..\common\scripte\copyRelease.bat'

beides lässt den xcopy befehl aus :(


tia
patrick


copyRelease.bat:

rem @echo off



"M:\mM4Setups\current\NSIS Source\common\programme\DIRCMP" /s M:\mediMACH\Releases\mediMACH4-%1 /t M:\mM4Setups\current\mM4Source\%2\mediMACH4 /m /q /w



xcopy.exe "M:\mediMACH\Kundenversionen\mediMACH4\*.*" "M:\mM4Setups\current\mM4Source\mediMACH4\" /E /Y


oops... i always thought xcopy is an internal command

i tested the following and i worked:

!system 'xcopy /s /e c:\test_ordner d:\3'


I tried calling it the way you did, but no luck.

do the files realy get copied? the compiler output say's !system returned 0, but actually nothing happened.

this is really odd. like I said when I call the batchfile from hand everything works fine, but when I call it from nsis during compiletime it never executes the xcopy command.


yes i see a list of files being copied. Is M:\ a drive mapping? If yes test a xcopy with local paths


yes m: is a drive mapping. i tried using just c: and it did not work either. it must have something to do with the way nsis executes shell commands. maybe it sees the xcopy command and then does not execute it, since it is a special command for nsis (doesn't it use xcopy to copy files onto a target system?)


try to run your batch file manually, i don't think, your xcopy-syntax is correct.

as first argument, u used a file specification:
"M:\mediMACH\Kundenversionen\mediMACH4\*.*"
but as second one just a directory:
"M:\mM4Setups\current\mM4Source\mediMACH4\"

use a directory OR a file specification in BOTH arguments, like this:
xcopy.exe "M:\mediMACH\Kundenversionen\mediMACH4" "M:\mM4Setups\current\mM4Source\mediMACH4" /E /Y


Hi,

thanks for the reply, but the syntax is correct and the batchFile when I start it from a command (cmd) shell works fine (as I stated in my first post ;), just calling it from NSIS it does not work. I also tried your syntax, with no difference.

thanks
patrick


Solution...
Use the robust copy command out of the windows resource kit.

!system '${InstallScriptInput}\robocopy /NFL /E "${ProductInput}\cd-Root" "${Output}" '


NSIS simply calls system() which calls %COMSPEC% /c <your command here>. Your problem might be that the COMSPEC environment variable is not defined correctly.


Hello,

I am facing the exact same problem. If you write a simple .bat file that does:

echo %COMSPEC%
xcopy /?

and execute it from your script with a !system call you'll notice that it does output the right COMSPEC but that the call to xcopy is simply bypassed and does not output anthing. I replaced xcopy by "c:\windows\system32\xcopy.exe" and got the same result. Of course, running this from anywhere displays the help message of xcopy...

Thanks,
mynab

PS: copy /? does work (but does not perform recursive file copy) so this seems to be xcopy related...


xcopy requires stdin which MakeNSISw doesn't provide. This problem was already fixed for nsExec, so fixing it again for MakeNSISw wasn't hard. Until 2.11, or the next nightly build, you can use makensis.exe directly.


Thanks you very much kichik!

Another almost related question: when I run makensis.exe using the /O flag all my output is nicely redirected to a file except the output of commands run with !system. Is there a may to make this output go to the /O specified log file the same way it merges in the makensisw.exe window?

Thanks
mynab


Use output redirection:

makensis.exe script.nsi > output.txt
To redirect errors to the file as well:
makensis.exe script.nsi > output.txt 2>&1
For more information:
http://www.robvanderwoude.com/redirection.html

Thanks I know redirections but in that case why did you put a /O switch to makensis? :)


I don't know, I didn't add it. It might be for easy redirection outside of a command prompt.