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






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值