0

The question is : what are the NET USE possible outputs?

You can drown yourself with websites explaining how to use NET USE command, but not a single one about what is coming out of it.

In my case I'm interested in the various error messages, and the interaction with the Powershell automatic variable $LASTEXITCODE. I want to handle its output correctly but I don't know what can even happen (and no, I won't use New-PSDrive).

Does someone knows the what or where I can find the information ?

Thanks

1 Answers1

0

You can use the example in https://www.compatdb.org/forums/topic/20487-net-use-return-code/ to obtain a list of the numerical codes for your evaluation.

If you want to dig deeper take you need to download the Win32 SDK and go through the definitions in the header files (see https://learn.microsoft.com/en-us/windows/win32/api/winnetwk/ns-winnetwk-netresourcea etc).

borealis-c
  • 146
  • 1
  • 6
  • Thank you for the approach. It's a little bit over my capacity, so I change my point of view and find a way to capture the returned error with the term `2>&1`. However, if you can explain a little bit more about the Win32 digging, that would be nice. I didn't see the link between that and the `net use` return. – Simon Jolin Aug 10 '22 at 08:26
  • Hi! Sorry, but I guess that would not work (at least I would be no great help in this case). Because if you pipe the error stream to analyse it, you would get the messages as text and the messages are localized. Therefore in my case the messages are in German, and even when installing an English version, I am not sure, that the localization would even be the same between US und UK. So maybe easist is to fake some "standard" error situations like wrong network share name, no network, etc. and extract those strings from your local environment and then add a general error for all other cases. – borealis-c Aug 11 '22 at 13:55