다음은 msiexec.exe를 호출하여 첫 번째 명령 줄 매개 변수에 전달 된 msi를 자동으로 설치하는 간단한 래퍼입니다.
는 그것은 비주얼 C++ 명령 줄 응용 프로그램으로 작성된 것 : 도움이
// 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;
}
희망을.
왜 직접 MSI를 사용할 수 없습니까? 사용자가 MSI 파일을 두 번 클릭하고 MSI가 배포한다는 의미입니까? –