我正在尝试从XML文件创建带有计划任务的Inno安装程序。计划的任务是:我的应用程序需要从用户登录开始。
在Inno安装脚本中:
[Run]
Filename: "schtasks.exe";
\Parameters: "/create /XML ""{app}\Schedule.xml"" /TN AppStart"在Schedule.xml文件中:
<Actions Context="Author">
<Exec>
<Command>"C:\Program Files\MyApp\MyApp.exe"</Command>
</Exec>
</Actions>这是正确的。但是我想将XML文件中的应用程序路径设置为{app}\MyApp.exe,因为用户可以在任何位置安装它。如何在安装程序运行时在XML文件中更改此路径?
发布于 2016-09-16 05:48:21
使用/TR开关,而不是使用XML指定要运行的路径。
[Run]
Filename: "schtasks.exe"; \
Parameters: "/Create /TR ""{app}\MyApp.exe"" /TN AppStart"如果您出于某种原因坚持使用XML,则必须动态创建该文件。
[Run]
Filename: "schtasks.exe"; \
Parameters: "/Create /XML ""{tmp}\Schedule.xml"""; \
BeforeInstall: CreateScheduleXML[Code]
procedure CreateScheduleXML;
var
FileName: string;
AppPath: string;
begin
FileName := ExpandConstant('{tmp}\Schedule.xml');
AppPath := ExpandConstant('{app}\MyApp.exe');
{ Create file here }
end;您可以使用像SaveStringsToUTF8File这样的简单函数创建文件,也可以使用MSXML2.DOMDocument COM对象(参见Edit installed XML file according to user preferences in Inno Setup)。
https://stackoverflow.com/questions/39520934
复制相似问题