Вопрос

I'm trying copy file to startup folder. Here is my code:

            String ^path;
            path = Environment::GetFolderPath(Environment::SpecialFolder::CommonStartup);
            path += "\\EFM.lnk";

            if(!IO::File::Exists(path))
                IO::File::Copy("C:\\lng\\EFM.lnk",path);

It's simple but don't working. I would like to ask you: "why"?

Это было полезно?

Решение

If the process lacks administrative rights and its manifest doesn't mark it as aware of UAC isolation, writes to the Common Startup folder (which requires administator access) may be silently redirected to C:\Users\{your name}\AppData\Local\VirtualStore.

This explains both the lack of file in the real folder and the lack of UnauthorizedAccessException or any other error.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top