retrodrone
retrodrone

Reputation: 5920

Calling Process.Start with invalid credentials

What happens if I call Process.Start with invalid credentials (i.e., password)? I'm getting a Win32Exception but that doesn't seem right to me. However, the documentation suggests it's not designed to report credential errors. Is this a security feature?

Upvotes: 1

Views: 351

Answers (1)

vcsjones
vcsjones

Reputation: 141638

No, Win32Exception is correct. If you look a little bit more on the MSDN documentation:

An error occurred when opening the associated file.

-or-

The sum of the length of the arguments and the length of the full path to the associated file exceeds 2080. The error message associated with this exception can be one of the following: "The data area passed to a system call is too small." or "Access is denied."

Emphasis mine.

I would say, that it isn't extremely clear. Looking at the code with reflector seems to agree with the documentation.

EDIT

Some plumbing details..

Process.Start will be throw a Win32Exception for a lot of reasons; pretty much if anything goes wrong starting the process. Internally, .NET is called CreateProcessWithLogonW, and if that fails, it throws the Win32Exception and sets the NativeErrorCode property on it to whatever GetLastWin32Error returned. You can determined why it was thrown by looking at that code. There is a lookup of what each code means here.

Upvotes: 3

Related Questions