msiexec无法打开此安装程序包

在编写应用程序宿主程序(支持自动部署与自动升级)时,需要在安装过程中安装vc runtime以及python环境,所以调用想调用 ""\"c:/windows/system32/msiexec.exe\" /i E:/Software/python-3.3.0.msi"".总是弹出“无法打开此安装程序包。请确认该程序包存在,并且您有权访问它,或者与应用程序供应商联系,以确认这是一个有效的 Windows Installer 程序包。”,经过两天的测试,终于摸索出以下规律.调用流程如下:

    char szCommandLine[MAX_PATH] = "\"c:/windows/system32/msiexec.exe\" /i E:/Software/python-3.3.0.msi";
    STARTUPINFO si;
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    PROCESS_INFORMATION pi;
    if(CreateProcess(NULL,szCommandLine,NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
    {
        CloseHandle(pi.hProcess);
        CloseHandle(pi.hThread);
    }
1、char szCommandLine[MAX_PATH] = "\"c:/windows/system32/msiexec.exe\" /i E:/Software/python-3.3.0.msi" : 出错

2、char szCommandLine[MAX_PATH] = "\"c:/windows/system32/msiexec.exe\" /i E:\\Software/python-3.3.0.msi" : 正确

3、char szCommandLine[MAX_PATH] = "\"c:/windows/system32/msiexec.exe\" /i E:\\Software\\python-3.3.0.msi" : 正确

4、char szCommandLine[MAX_PATH] = "\"c:/windows/system32\\msiexec.exe\" /i E:\\Software\\python-3.3.0.msi" : 正确

5、char szCommandLine[MAX_PATH] = "\"c:/windows\\system32\\msiexec.exe\" /i E:\\Software\\python-3.3.0.msi" : 正确

6、char szCommandLine[MAX_PATH] = "\"c:\\windows\\system32\\msiexec.exe\" /i E:\\Software\\python-3.3.0.msi" : 正确

结论:

    对于"msiexec"而言,解析安装包目录时,驱动符号后面的目录分隔符必须是'\\'而不能是'/'。也再一次印证了原先的感概:微软,我心中永远痛 - 错与不错看心情,导与不导看运气,有时是向导,有时是误导。






你可能感兴趣的:(msiexec无法打开此安装程序包)