Domanda

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"?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top