Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

nsExec::ExecToStack fails when running NSIS script tring to run DOS command

Please note that I am attempting to create a data file as part of my installation script. Here is what I am using:

  # Create config.dat based on user`s previous selection
  nsExec::ExecToStack '"$SYSDIRcmd.exe" @echo ServerPort = 2003 > $INSTDIRconfig.dat'
  Pop $0 # return value/error/timeout
  Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
  DetailPrint '$SYSDIRcmd.exe "@echo ServerPort = 2003 > $INSTDIRconfig.dat" printed: $1'
  DetailPrint ""
  DetailPrint "       Return value: $0"
  DetailPrint ""

When I run the script, the above returns a 0, so I think it should have worked but when I check the installation directory I see that no config.dat file has been created.

Also, I have tried this command,

nsExec::ExecToStack '@echo ServerPort = 2003 > $INSTDIRconfig.dat'

But when I use it the display prints:

Return value: error

Here are websites I have looked at but it is still not clear to me how to get nsExec working.

Does anyone have any suggestions? TIA.

question from:https://stackoverflow.com/questions/65947000/nsexecexectostack-fails-when-running-nsis-script-tring-to-run-dos-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please note that I have found the issue. I thought nsExec mainly worked with the command line, but you have to start with cmd:

nsExec::ExecToStack  'cmd /c "@echo ServerPort = 2003 > config.dat"'

For details please see:

Execute Command-Line Command from NSIS


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...