# 安装msi文件报错2503和2502

## 原因分析

安装 `TortoiseSVN.msi` 或者 `msi` 之类的程序过程中报错 `2503` 或者 `2502` ,主要使用户的权限不够大,在右键安装时无法像 `exe` 执行文件选择"以管理员身份运行"

![2502](https://github.com/ougege/blog/blob/master/Images/Windows/Windows安装.msi文件报错2502或2503/2502.jpg)

![2503](https://github.com/ougege/blog/blob/master/Images/Windows/Windows安装.msi文件报错2502或2503/2503.jpg)

## 网上解决办法

### 一、修改组策略: 对应用程序始终以提升的权限进行安装(失败,依然报错)

1. 使用 `win+R` 命令打开运行,输入 `gpedit.msc` 进入本机计算机策略
2. `计算机配置`-> `管理模板` -> `windows组件` -> `windows installer` 然后选择右侧的 **始终以提升的权限进行安装**
3. 右键编辑,选中 `以启用` ,确定 ![组策略编辑](https://github.com/ougege/blog/blob/master/Images/Windows/Windows安装.msi文件报错2502或2503/gpedit.png)

### 二、使用命令行安装: 进入管理员命令行,执行安装(安装成功,单安装目录下的可执行文件无法被执行)

1. 以管理员身份运行 `cmd`
2. 输入安装命令和安装文件所在目录

![命令行安装](https://github.com/ougege/blog/blob/master/Images/Windows/Windows安装.msi文件报错2502或2503/terminal.png)

### 三、修改注册表: 给msi安装包右键菜单里添加`以管理员身份运行`选项(成功)

1. 通过 `win+R` 打开 `运行` ,输入 `regedit` ,打开注册表编辑器
2. 在左侧列表中定位至 `HKEY_CLASSES_ROOT\Msi.Package\shell`
3. 右侧点击 `shell` ,选择 `新建-项` ,然后重命名为 `runas` ,选中 `runas`项，双击右侧窗口 `默认` 字符串,把数值数据修改为 `以管理员身份运行`

   ![注册表编辑器](https://github.com/ougege/blog/blob/master/Images/Windows/Windows安装.msi文件报错2502或2503/regedit.png)
4. 在 `runas` 项下载新建一个 `command` 项,同样把右侧 `默认` 字符串数值数据修改为 `msiexec /i"%1"`
5. 结论: 重新右键点击 `msi` 文件,选择 `以管理员身份运行`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ougege.gitbook.io/blog/docs/articles/windows/an-zhuang-msi-wen-jian-bao-cuo-2503-he-2502.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
