开发者

How to write bootstrap EXE, which launch MSIEXEC.EXE and then wait for its completion

I'm trying to install my ActiveX plugin, packaged in nsi in a cab file, and encountered a problem.

The log is

Code Download Error: (hr = 80070005) Access is denied.

ERR: Run Setup Hook: Failed Error Code:(hr) = 80070005, processing: msiexec.exe /package "%EXTRACT_DIR%\TempR.msi"

I think is the same as this one:

http://social.msdn.microsoft.com/Forums/en-US/ieextensiondevelopment/thread/3d355fb6-8d6a-4177-98c2-a25665510727/

I want to try the solution that is suggested there, but has no idea how to

create a small bootstrap EXE, whi开发者_JAVA技巧ch does nothing but to launch MSIEXEC.EXE and then wait for its completion.

Can someone provide any help?

Thanks!!


Here is a simple wrapper that calls msiexec.exe to quietly install the msi passed in the first command line parameter.

It's written as a Visual C++ command line application:

// InstallMSI.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
#include <string>

int wmain(int argc, wchar_t* argv[])
{
if(argc < 2) {
    printf("Usage: installmsi.exe <full path to msi file>\n\n");
    printf("Package will be installed using msiexec.exe with the /qn (quiet install) flags.\n");
    return 1;
}

std::wstring args;
args = L"msiexec.exe /i \"";
args += argv[1];
args += L"\" /qn";

PROCESS_INFORMATION pi;
STARTUPINFO si;

ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);

ZeroMemory(&pi, sizeof(pi));

if(!CreateProcess(NULL, (LPWSTR)args.c_str(),
    NULL, NULL, TRUE, NULL, NULL, NULL, &si, &pi)) {
        printf("CreateProcess failed (%d).\n", GetLastError());
        return 2;
}

WaitForSingleObject( pi.hProcess, INFINITE );

CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

return 0;
}

Hope that helps.


Take a look at dotNetInstaller - prewritten bootstrapper program that does lots more than what you need, but can do just exactly what you're asking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜