有时候,一些本地命令,比如net.exe,在执行过程中,会返回数字编号形式的错误信息。很郁闷的是,我们不知道这些数字代表什么意思。以前,我们可以使用如下的方式去获取数字代表的信息:

复制代码 代码如下:

PS> net helpmsg 3534
The service did not report an error.

PS> net helpmsg 1
Incorrect function.

PS> net helpmsg 4323
The transport cannot access the medium.


其实有一个更好的方法,那就是使用winrm.exe,它不仅可以实现上面的功能,而且还要更加强大!同样的,看看对上面三个错误的翻译:
复制代码 代码如下:

PS> winrm helpmsg 3534
The service did not report an error.

PS> winrm helpmsg 1
Incorrect function.

PS> winrm helpmsg 4323
The transport cannot access the medium.


OK,看到了吧,结果是一样的。其实,net.exe只能翻译中一个特定规范内的错误信息(具体怎么样一个特定的规范,洪哥也不是很清楚),而winrm.exe则要更加强大,比如它可以转换“特定的远程”错误代码:
复制代码 代码如下:

PS> winrm helpmsg 0x80338104
The WS-Management service cannot process the request. The WMI service returned an 'access denied' error.

PS> net helpmsg 0x80338104
The syntax of this command is:
NET HELPMSG
message#


上面可以看出来,winrm.exe正确的翻译出了0x80338104的错误信息,而net.exe没有做到。其实,这个命令可能跟PowerShell没有什么直接的关系,但也算是一个Shell命令吧,我们可以使用它去翻译任何低级的API错误代码,并且坚定的相信它得到的结果。

点赞(79)

评论列表共有 0 条评论

立即
投稿
返回
顶部