I can't create a shortcut or even create a folder inside C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\
and get an "Access is denied" error in both cases. I am using C++(WinAPI) and am interested in creating a shortcut inside that folder. Code for creating shortcut is working perfectly for other locations(for example for creating shortcuts on Desktop). How can I workaround this error?
Writing to the All-users start menu requires UAC rights. So, you'll need to run your application as administrator. Or just use the current-user start menu "C:\Users\[CurrentUser]\AppData\Roaming\Microsoft\Windows\Start Menu"
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
string StartMenuLocation=
(string)getenv("HOMEDRIVE")+"\\Users\\"+(string)getenv("USERNAME")+"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu";
cout<<StartMenuLocation;
cin.get();
}
Hope this helps.