简体   繁体   English

从 Inno Setup 执行带有输出重定向的程序

[英]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.

相关问题 Inno Setup 中的输出重定向如何工作? - How does output redirection work in Inno Setup? 在 Inno Setup 中以管理员权限执行安装后程序 - Execute postinstall program with administrator privileges in Inno Setup 安装后执行批处理文件并在 Inno Setup 中的 Finished 页面之前在自定义页面上显示其输出 - Execute a batch file after installation and display its output on a custom page before Finished page in Inno Setup 从Inno Setup从安装该程序的文件夹中读取Delphi程序中的文件 - Read a file in Delphi program from a folder where the program is installed to by Inno Setup 如果未安装其他程序,请跳过 Inno Setup 中的安装 - Skip installation in Inno Setup if other program is not installed Inno Setup - 卸载程序时从 PATH 环境变量中删除路径 - Inno Setup - Remove path from PATH environment variable while uninstalling a program Inno Setup仅在第一个应用程序完成后才执行第二个应用程序 - Inno Setup execute second app only if first app finished 在 Inno Setup 中从 XML 导入计划任务 - Import a scheduled task from XML in Inno Setup 如何从反编译中保护/加密 Inno Setup - How to secure/encrypt Inno Setup from decompiling 从 Inno Setup 向 GAC 添加程序集 - Adding assemblies to the GAC from Inno Setup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM