PowerShell Cookbook

Twitter Updates

    follow me on Twitter

    Search

    Categories

     

    On this page

    PowerShell equivalent of NET HELPMSG

    Archive

    Blogroll

    Disclaimer
    I work for Microsoft.

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    RSS 2.0 | Atom 1.0 | CDF

    Send mail to the author(s) E-mail

    Total Posts: 252
    This Year: 3
    This Month: 0
    This Week: 0
    Comments: 736

    Sign In

     Monday, September 14, 2009
    Tuesday, September 15, 2009 12:33:05 AM (Pacific Daylight Time, UTC-07:00) ( )

    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.

    Comments [0] | | #