Discussion:
Access rights needed for SetCurrentDirectory()?
(too old to reply)
Vincent Fatica
2010-05-28 20:50:36 UTC
Permalink
What access rights are needed for SetCurrentDirectory() to succeed? I'd like to
know id SetCurrentDirectory will succeed without actually calling it. Thanks.
--
- Vince
Alex Blekhman
2010-05-29 02:26:16 UTC
Permalink
Post by Vincent Fatica
What access rights are needed for SetCurrentDirectory() to succeed? I'd like to
know id SetCurrentDirectory will succeed without actually calling it. Thanks.
I think that SetCurrentDirectory should always succeed because it
doesn't change the system, but only changes the process itself. MSDN
says that SetCurrentDirectory changes global environment variable in a
calling process. I am not aware of any access rights restriction that
would prevent a process from setting its own env. variables.

I don't know whether SetCurrentDirectory checks if requested directory
actually exists. If yes, then reading a disk would be reasonable access
right to expect from a calling process.

HTH
Alex
Vincent Fatica
2010-05-29 04:13:50 UTC
Permalink
On Sat, 29 May 2010 12:26:16 +1000, Alex Blekhman <***@yahoo.com> wrote:

|On 29-May-10 6:50, Vincent Fatica wrote:
|>
|> What access rights are needed for SetCurrentDirectory() to succeed? I'd like to
|> know id SetCurrentDirectory will succeed without actually calling it. Thanks.
|
|I think that SetCurrentDirectory should always succeed because it
|doesn't change the system, but only changes the process itself. MSDN
|says that SetCurrentDirectory changes global environment variable in a
|calling process. I am not aware of any access rights restriction that
|would prevent a process from setting its own env. variables.
|
|I don't know whether SetCurrentDirectory checks if requested directory
|actually exists. If yes, then reading a disk would be reasonable access
|right to expect from a calling process.

It fails on "System Volume Information" for example. And it fails when the
target doesn't exist. The current directory is rather important to other Win32
API functions. It's **the** place to look when CreateFile() is given a name
with no path.
--
- Vince
Alex Blekhman
2010-05-29 05:30:43 UTC
Permalink
Post by Vincent Fatica
It fails on "System Volume Information" for example. And it fails when the
target doesn't exist.
Good to know. However, "System Volume Information" is a quite special
folder. I couldn't open it even with Administrator rights. Even file
listing is denied.

Alex

Loading...