简体   繁体   中英

Calling Process.Start with invalid credentials

What happens if I call Process.Start with invalid credentials (ie, 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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM