PowerShell equivalent of NET HELPMSG

Tue, Sep 15, 2009 2-minute read

Sometimes, people ask, “What’s the equivalent of NET HELPMSG” in PowerShell?

NET HELPMSG is probably the easiest to remember (and works in PowerShell of course,) but PowerShell improves the experience a bunch by way of the .NET Framework.

Suppose you get error 0x80070652 from an installer:

C:\Users\leeholm>net helpmsg 0x80070652
The syntax of this command is:

NET HELPMSG
message#

Oops, it doesn’t support hex. You need to take the last 4 digits:

C:\Users\leeholm>net helpmsg 0652
0652 is not a valid Windows network message number.

More help is available by typing NET HELPMSG 3871.

Oops, forgot to convert it to decimal.

C:\Users\leeholm>set /a c = 0x652
1618
C:\Users\leeholm>net helpmsg 1618

Another installation is already in progress. Complete that installation before proceeding with this install.

Perfect.

No matter your preference, PowerShell makes this easier. The System.ComponentModel.Win32Exception class supports constructors for all of the main scenarios, so PowerShell’s type casting support gives another way (albeit with a slightly ungainly syntax:)

[D:\documents\tools]
PS:163 > [ComponentModel.Win32Exception] 0x80070652
Another installation is already in progress. Complete that installation before proceeding with this install

[D:\documents\tools]
PS:164 > [ComponentModel.Win32Exception] 0x80070652
Another installation is already in progress. Complete that installation before proceeding with this install

[D:\documents\tools]
PS:165 > [ComponentModel.Win32Exception] –2147023278
Another installation is already in progress. Complete that installation before proceeding with this install

[D:\documents\tools]
PS:166 > [ComponentModel.Win32Exception] 0x0652
Another installation is already in progress. Complete that installation before proceeding with this install

[D:\documents\tools]
PS:167 > [ComponentModel.Win32Exception] 1618
Another installation is already in progress. Complete that installation before proceeding with this install

So don’t go replacing all of your NET HELPMSG muscle memory, but when you find yourself struggling with the requirements, give the [ComponentModel.Win32Exception] class a try.