﻿# 介紹好用工具：MS Exchange Server Error Code Look-up

今天在事件檢視器上看到一個錯誤，錯誤訊息是《節點無法加入容錯移轉叢集 'XXXCluster'，因為發生錯誤，錯誤碼是 '183'。》如果各位看到這種錯誤你說該怎麼辦？**錯誤碼是 '183'**，183 這個魔術數字 ([Magic Number](http://en.wikipedia.org/wiki/Magic_number_\(programming\))) 誰知倒是什麼東西阿，以前的我會先企圖把中文翻譯成英文然後去 Google 查資料，不過現在我會先利用微軟寫的這個 [Microsoft Exchange Server Error Code Look-up](http://web.archive.org/web/20120102151213/http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=985) 先幫我找找錯誤代碼所代表的意思再進行查詢，精準搜尋的結果或許能讓你有更不一樣的收穫喔！

![Microsoft Exchange Server Error Code Look-up](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/880419d18f7a360db7fe-image_252.png "title")

這個工具雖然從名稱看起是給 Microsoft Exchange Server 之用，不過由於 Exchange Server 用到許多 Windows 作業系統內建的 API 或函示庫，因此這個工具也內建了許多在 Windows 作業系統中定義的各式 API 回傳碼 (Return Code)，在我下載的 6.0.4011.0 版就包括了 19,871 個回傳碼定義，可以幫你快速取得這個錯誤碼或回傳碼的定義。

註：關於回傳碼可以參考筆者的《 [程式結束狀態: Windows 的 %ERRORLEVEL% 與 Linux 的 $?](/post/2010/10/04/Windows-Batch-ERRORLEVEL-and-Linux-Bash-Exit-Status.aspx) 》文章

在下載完 [Microsoft Exchange Server Error Code Look-up](http://web.archive.org/web/20120102151213/http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=985) 之後你會拿到一個 **Err.exe** 執行檔，這是一個會自動解壓縮的執行檔，你可以自己決定解壓縮的位置，例如我選擇：C:\\Program Files

![alt](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/38cd0adc2381227d52ae-image_253.png "title")  ![alt](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/92def327f0d9f4cb078b-image_254.png "title")

安裝好之後會在解壓縮目錄的 Err 子目錄下看到一個 **Err.exe** 執行檔，這是一個指令列的執行檔：

![安裝好之後會在解壓縮目錄的 Err 子目錄下看到一個 Err.exe 執行檔，這是一個指令列的執行檔](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/9b90f10c0e2c2ad7ff56-image_255.png "title")

這時我們就可以進入**命令提示字元**執行 **Err.exe** 執行檔並加上錯誤碼參數，例如： (點圖可放大)

[![編號 1 是 Err.exe 在哪個 Header 檔案中找到錯誤碼的定義，編號 2 是找到的常數定義，編號 3 是對應的註解，而這個註解正是可以幫我們更容易利用 Google 大神找到解答的關鍵！](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/58584a5c1874a8250251-image_thumb_31.png "title")](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/3a553cc7fd2e68c571ae-image_256.png)

如上圖示，編號 1 是 **Err.exe** 在哪個 Header 檔案中找到錯誤碼的定義，編號 2 是找到的常數定義，編號 3 是對應的註解，而這個註解正是可以幫我們更容易利用 Google 大神找到解答的關鍵！

如果你得到的錯誤碼是 16 進位表示的話，也可以利用 **Err.exe** 查詢，例如：

```
err 0xb7
```

事實上可以查詢的格式很多，適用於各種產品或從事件檢視器中查到的錯誤代碼，支援的格式如下：

-   Decorated hex (**0x54f**)
-   Implicit hex (**54f**)
-   Ambiguous (**1359**)
-   Exact string (**\=ERROR\_INTERNAL\_ERROR**)
-   Substring (**:INTERNAL\_ERROR**)

例如你要搜尋所有與 LDAP 相關的回傳代碼可以執行以下指令，這是一種 Substring 的查詢語法：

```
err :LDAP
```

此工具在對 Windows 各產品或內建服務進行 [Troubleshooting](http://en.wikipedia.org/wiki/Troubleshooting) 時不失為一個好用工具啊！ (rock)

**補充說明**

感謝 [ChrisTorng](http://facebook.com/ChrisTorng1) 網友提供額外資訊，原來在 Visual Studio 裡面就有內建一個 **errlook.exe** 工具也可以用來查詢錯誤碼喔，程式路徑在：

Visual Studio 2008

```
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\errlook.exe
```

Visual Studio 2010

```
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\errlook.exe
```

這是一個有圖形視窗介面 (GUI) 的查詢工具，還算簡單易用且內建於 Visual Studio 之中，對開發人員來說不用額外安裝，有興趣的人也可以試試：

![Error Lookup](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/36cfeb84391237f40c6d-SNAGHTML4abb11e.png "Error Lookup")

**相關連結**

-   [Microsoft Exchange Server Error Code Look-up](http://web.archive.org/web/20120102151213/http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=985)
