CreateProcessAsUser with long path

Hi,

I’m unable to create a process that has a path longer than MAX_PATH.
I’ve used the UNC prefix \\?\ and it still doesn’t work. I get error 267 (Directory name is invalid).
I also turned on Win32 long paths in the local group policies, and executed gpupdate with the /force switch before executing my test app.
My code works without issues if the path is under MAX_PATH chars long.

So my question is, is this a limitation of the CreateProcessAsUser() API?

I read on various forums that CreateFile supports long paths but CreateProcess doesn’t.
Is that true?

Upon further investigation it turned out that I can create a process with long paths, only if the lpCurrentDirectory parameter passed to the CreateProcessAsUser() api is under MAX_PATH characters. In my code I was using the parent directory of the EXE as the current directory which indeed was a long path and therefore was causing an error.

1 Like