IKM2007
IKM2007

Reputation: 726

Creating shortcut inside windows start menu

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?

Upvotes: 0

Views: 1415

Answers (1)

xxx
xxx

Reputation: 54

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.

Upvotes: 2

Related Questions