11 int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int nShowCmd)
12 {
13 JP_TRY;
14
15 // Create temporary directory where to extract msi file.
16 const auto tempMsiDir = FileUtils::createTempDirectory();
17
18 // Schedule temporary directory for deletion.
19 FileUtils::Deleter cleaner;
20 cleaner.appendRecursiveDirectory(tempMsiDir);
21
22 const auto msiPath = FileUtils::mkpath() << tempMsiDir << L"main.msi";
23
24 // Extract msi file.
25 Resource(L"msi", RT_RCDATA).saveToFile(msiPath);
26
27 // Setup executor to run msiexec
28 Executor msiExecutor(SysInfo::getWIPath());
29 msiExecutor.arg(L"/i").arg(msiPath);
30 const auto args = SysInfo::getCommandArgs();
31 std::for_each(args.begin(), args.end(), [&msiExecutor] (const tstring& arg) {
32 msiExecutor.arg(arg);
33 });
34
35 // Install msi file.
36 return msiExecutor.execAndWaitForExit();
37
38 JP_CATCH_ALL;
39
40 return -1;
41 }
|
11 int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int nShowCmd)
12 {
13 JP_TRY;
14
15 // Create temporary directory where to extract msi file.
16 const auto tempMsiDir = FileUtils::createTempDirectory();
17
18 // Schedule temporary directory for deletion.
19 FileUtils::Deleter cleaner;
20 cleaner.appendRecursiveDirectory(tempMsiDir);
21
22 const auto msiPath = FileUtils::mkpath() << tempMsiDir << L"main.msi";
23
24 // Extract msi file.
25 Resource(L"msi", RT_RCDATA).saveToFile(msiPath);
26
27 // Setup executor to run msiexec
28 Executor msiExecutor(SysInfo::getWIPath());
29 msiExecutor.arg(L"/i").arg(msiPath);
30 const auto args = SysInfo::getCommandArgs();
31 std::for_each(args.begin(), args.end(),
32 [&msiExecutor] (const tstring& arg) {
33 msiExecutor.arg(arg);
34 });
35
36 // Install msi file.
37 return msiExecutor.execAndWaitForExit();
38
39 JP_CATCH_ALL;
40
41 return -1;
42 }
|