Hi,
Trying to use ExecWait (NSIS2, ModernUI) in a section to redirect external program output to file:
SetOutPath $INSTDIR
File "memory.exe"
ExecWait '"$INSTDIR\memory.exe" > "$INSTDIR\memory.txt"' $0
IfErrors e1 e2
e1:
MessageBox MB_OK "Error = $0"
goto e3
e2:
MessageBox MB_OK "OK"
e3:
ExecWait returns no error, yet file is not created. Any ideas?
Thanks.
ExecWait with file redirection
7 posts
This thread should help you:
BTW, you might also want to try out nsExec, maybe it can help you too.
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
BTW, you might also want to try out nsExec, maybe it can help you too.
Thanks for the link Kichik.
Here is the the code that worked for me:
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\memory.exe" > "$INSTDIR\mem.txt"' $0
Here is the the code that worked for me:
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\memory.exe" > "$INSTDIR\mem.txt"' $0
Hi,
I guess I have a some-what similar problem.
I am trying to pipe my output to a log file and I have attempt the below 3 options but none of them creates the test.log file.
Could someone please help. Thanks.
ExecWait 'call "$INSTDIR\test.bat" "2> $INSTDIR\test.log"' $0
ExecWait 'call "$INSTDIR\test.bat" 2> "$INSTDIR\test.log"' $0
ExecWait "call $INSTDIR\test.bat 2> $INSTDIR\test.log" $0
🙁
I guess I have a some-what similar problem.
I am trying to pipe my output to a log file and I have attempt the below 3 options but none of them creates the test.log file.
Could someone please help. Thanks.
ExecWait 'call "$INSTDIR\test.bat" "2> $INSTDIR\test.log"' $0
ExecWait 'call "$INSTDIR\test.bat" 2> "$INSTDIR\test.log"' $0
ExecWait "call $INSTDIR\test.bat 2> $INSTDIR\test.log" $0
🙁
Use the code above:
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\test.bat" > "$INSTDIR\test.log"' $0
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\test.bat" > "$INSTDIR\test.log"' $0
Originally posted by kichikEvery time I put double quotes around the output file I get an errorlevel of 1.
Use the code above:
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\test.bat" > "$INSTDIR\test.log"' $0
After about try 1038 I decided to try taking the quotes out.
It started working.
strcpy $BACKUPFILE "$TEMP\ADMIN_DB_MYSQL_BACKUP.sql"
strcpy $BACKUPFILE_PREPARED "$TEMP\ADMIN_DB_MYSQL_BACKUP_PREPARED.sql"
strcpy $1 $BACKUPFILE
ExpandEnvStrings $2 %COMSPEC%
Before:
ExecWait '"$2" /C "$INSTDIR\bin\mysqldump.exe" --quick --add-drop-table --extended-insert --force --user=username --password=password database > "$1"' $0
After:
ExecWait '"$2" /C "$INSTDIR\bin\mysqldump.exe" --quick --add-drop-table --extended-insert --force --user=username --password=password database > $1' $0
The reason I resorted to $1 instead of $BACKUPFILE was that I thought variable expansion wasn't working correctly, so sorry for the unnecessary confusion.
Any reason why the first attempt didn't work?
Thanks!
Brandon
cmd.exe sucks, though probably for a reason. Add a IF 1==1 prefix to your command.
ExecWait '"$2" /C IF 1==1 "$INSTDIR..." ...