16,471
社区成员
发帖
与我相关
我的任务
分享
[Setup]
AppName=Example
AppVersion=1.0
DefaultDirName=Example
[Files]
Source: "C:\1\_ISDEL.EXE"; DestDir: "{tmp}\wr"
Source: "C:\1\_SETUP.1"; DestDir: "{tmp}\wr"
Source: "C:\1\_SETUP.DLL"; DestDir: "{tmp}\wr"
Source: "C:\1\_SETUP.LIB"; DestDir: "{tmp}\wr"
Source: "C:\1\DISK1.ID"; DestDir: "{tmp}\wr"
Source: "C:\1\SETUP.INI"; DestDir: "{tmp}\wr"
Source: "C:\1\SETUP.INS"; DestDir: "{tmp}\wr"
Source: "C:\1\SETUP.PKG"; DestDir: "{tmp}\wr"
Source: "C:\1\setup.iss"; DestDir: "{tmp}\wr"
Source: "C:\1\SETUP.EXE"; DestDir: "{tmp}\wr"; AfterInstall: MyAfterInstall1
Source: "C:\2\Install.exe"; DestDir: "{tmp}"; AfterInstall: MyAfterInstall2
[Code]
procedure MyAfterInstall1();
var
ResultCode: Integer;
begin
Exec(ExpandConstant(CurrentFileName), '-s', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
procedure MyAfterInstall2();
var
ResultCode: Integer;
begin
Exec(ExpandConstant(CurrentFileName), '/verysilent sp-', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
再改了一下
[Setup]
AppName=Example
AppVersion=1.0
DefaultDirName=Example
[Files]
Source: "C:\1\_ISDEL.EXE"; DestDir: "{tmp}"
Source: "C:\1\_SETUP.1"; DestDir: "{tmp}"
Source: "C:\1\_SETUP.DLL"; DestDir: "{tmp}"
Source: "C:\1\_SETUP.LIB"; DestDir: "{tmp}"
Source: "C:\1\DISK1.ID"; DestDir: "{tmp}"
Source: "C:\1\SETUP.INI"; DestDir: "{tmp}"
Source: "C:\1\SETUP.INS"; DestDir: "{tmp}"
Source: "C:\1\SETUP.PKG"; DestDir: "{tmp}"
Source: "C:\1\SETUP.EXE"; DestDir: "{tmp}"; AfterInstall: MyAfterInstall1
Source: "C:\2\Install.exe"; DestDir: "{tmp}"; AfterInstall: MyAfterInstall2
[Code]
procedure MyAfterInstall1();
var
ResultCode: Integer;
begin
// 假设安装包 A 的静默参数为 /S
Exec(ExpandConstant(CurrentFileName), '/S', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
procedure MyAfterInstall2();
var
ResultCode: Integer;
begin
// 假设安装包 B 的静默参数为 /S
Exec(ExpandConstant(CurrentFileName), '/S', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
[Setup]
AppName=Example
AppVersion=1.0
DefaultDirName=Example
[Files]
Source: "C:\test\PackageA.exe"; DestDir: "{tmp}"; AfterInstall: MyAfterInstallA
Source: "C:\test\_ISDEL.EXE"; DestDir: "{app}"
Source: "C:\test\_SETUP.1"; DestDir: "{app}"
Source: "C:\test\_SETUP.DLL"; DestDir: "{app}"
Source: "C:\test\_SETUP.LIB"; DestDir: "{app}"
Source: "C:\test\DISK1.ID"; DestDir: "{app}"
Source: "C:\test\SETUP.INI"; DestDir: "{app}"
Source: "C:\test\SETUP.INS"; DestDir: "{app}"
Source: "C:\test\SETUP.PKG"; DestDir: "{app}"
Source: "C:\test\SETUP.EXE"; DestDir: "{app}"; AfterInstall: MyAfterInstallB
Source: "C:\wrnew\wr.exe"; DestDir: "C:\wr"
[Code]
procedure MyAfterInstallA();
var
ResultCode: Integer;
begin
// 假设安装包 A 的静默参数为 /S
Exec(ExpandConstant(CurrentFileName), '/S', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
procedure MyAfterInstallB();
var
ResultCode: Integer;
begin
// 假设安装包 B 的静默参数为 /S
Exec(ExpandConstant(CurrentFileName), '/S', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
// CopyFile('C:\dirB\wr.exe', 'C:\wr\wr.exe');
end;
如果两个包的静默参数相同,你直接写一个函数就可以了。根据你列举的文件名看起来 B 也是一个安装包。那么其实你可以将 B 的主 exe 放在最后释放,并同样书写 AfterInstall 函数去安装 B。然后将新文件打包并释放到你说的那个目录。如果新文件 wr.exe 来自于 B 安装之后,File 段的 wr.exe 就不用打包了,直接用 Code 段注释的那行代码。void main( VOID )
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
"MyChildProcess", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
ErrorExit( "CreateProcess failed." );
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}