[英]Execute program with output redirection from Inno Setup
I am trying to make a database backup on uninstall but for some reason program with redirection always fails in Inno Setup.我正在尝试在卸载时进行数据库备份,但由于某种原因,带有重定向的程序在 Inno Setup 中总是失败。 Here is what I have:
这是我所拥有的:
[Run]
Filename: "{#DB_PATH}\mysqldump.exe"; \
Parameters: "-c --compact {#DB_NAME} > {#STORAGE_PATH}\db.sql"; Flags: runhidden;
Filename: "xcopy"; \
Parameters: "{#STORAGE_PATH} {userdesktop}\Backup\ /E/H"; Flags: runhidden;
Filename: "{#DB_PATH}\mysqladmin.exe"; \
Parameters: "shutdown"; Flags: runhidden;
The last two commands works correctly.最后两个命令正常工作。 But the first one never works for some reason.
但由于某种原因,第一个永远不会奏效。 I've already tested the command and it works without any issues.
我已经测试了该命令,它可以正常工作。
I am not sure if am doing something wrong so any help is appreciated.我不确定我是否做错了什么,所以感谢任何帮助。
This seems to be a variation of:这似乎是以下情况的变体:
How does output redirection work in Inno Setup? Inno Setup 中的输出重定向如何工作?
With small difference, that you are using [Run]
section and not Pascal Script code.有一点不同,您使用的是
[Run]
部分而不是 Pascal Script 代码。
The output redirection syntax is a feature of the command prompt, not the core Windows APIs.
输出重定向语法是命令提示符的一项功能,而不是核心 Windows API。 Therefore if you want to redirect output then you need to invoke the command via
{cmd} /c actual-command-line > output-file
.因此,如果要重定向输出,则需要通过
{cmd} /c actual-command-line > output-file
调用命令。
So it should be:所以应该是:
Filename: "{cmd}"; \
Parameters: "/C {#DB_PATH}\mysqldump.exe -c --compact {#DB_NAME} > {#STORAGE_PATH}\db.sql"; \
Flags: runhidden;
But you should quote all paths as well (and due to obscure syntax that cmd.exe
uses, you then need to quote whole command as well):但是您也应该引用所有路径(并且由于
cmd.exe
使用的语法晦涩,您还需要引用整个命令):
Filename: "{cmd}"; \
Parameters: "/C """"{#DB_PATH}\mysqldump.exe"" -c --compact {#DB_NAME} > ""{#STORAGE_PATH}\db.sql"""""; \
Flags: runhidden;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.