I am trying to create a symbolic link from a custom action dll using Wix installer.
The custom action is run as an administrator and I confirmed it by using code from:
http://code.msdn.microsoft.com/windowsdesktop/CppUACSelfElevation-5bfc52dd
The problem is that on Windows 8 the symbolic link is created, however on Windows 7 error 1314
is returned:
ERROR_PRIVILEGE_NOT_HELD1314 (0x522)
A required privilege is not held by the client.
Both Windows 7 and Windows 8 users are capable of running the process as administrators.
Any idea how I can solve this issue please?
Regards,
Noel
The error isn't telling you you don't have access rights, it's telling you you don't have privilege . Certain privileges need to be requested explicitly under certain versions of the OS. Windows 7 seemed to to have SeCreateSymbolicLinkPrivilege off even with administrator access.
Pseudo code, but I believe you have to adjust privileges for your process token before calling CreateSymbolicLink
LUID luid;
if(LookupPrivilegeValue(NULL, _T("SeCreateSymbolicLinkPrivilege"), &luid))
{
HANDLE hToken = get_process_token();
TOKEN_PRIVILEGES token_privileges;
token_privileges.PrivilegeCount = 1;
token_privileges.Privileges[0].Luid = luid;
token_privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(!AdjustTokenPrivileges(hToken, FALSE, &token_privileges, 0, NULL, NULL))
{
// TODO: call GetLastError and report an error.
}
}
What I found out is that with an MSI installer on Windows 7 or Vista Windows will not let you create a Symbolic link even if the installer is run as an administrator. What I ended up doing is by wrapping the .msi installer into an .exe using InnoSetup and ran the symbolic link commands from the executable.
On windows 8 this works because the Installer version has changed.
Hope this helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.