Hello, have build that simple app with VS2010 which adds a registry key in HKCU/SOFTWARE/MICROSOFT/WINDOWS/CURRENT VERSION/RUN and prints a message when it runs.
Here is the code :
#include "stdafx.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <winbase.h>
void regedit();
int main()
{
regedit();
MessageBox(NULL,"test","TEST",MB_OK);
return 0;
}
void regedit()
{
LPCTSTR regPathRun = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
int ro, sizeOfPath;
char buffer[300];
HKEY hKey;
char *appPath;
char finalPath[200];
ro = 0;
if(ro == 0)
{
sizeOfPath = GetModuleFileName(NULL,buffer,300);
appPath = buffer;
_snprintf(finalPath, sizeOfPath+2, "\"%s\"", appPath);
finalPath[sizeOfPath+2] = '\0';
if(RegOpenKeyEx(HKEY_CURRENT_USER,regPathRun,0,KEY_ALL_ACCESS,&hKey) == ERROR_SUCCESS)
{
RegSetValueEx(hKey,"proper",0,REG_SZ,finalPath,sizeOfPath+2);
RegCloseKey(hKey);
}else{
}
ro++;
}
}
i compile it as a console application on a WinXP. Next, i ran it on a WIN 7 machine through cmd and it runs properly without trigger the UAC. Although after a restart , while the reg key has been added, i'm getting UAC window popped up. The question is how can i make it not to be triggered when that app is going to run.
I look for it on the net and even here there are posts that talk about the manifest file. So in my projects debug folder there are two manifest files:
1)JustReg.exe.embed.manifest
2)JustReg.exe.intermediate.manifest
which has this content:
1)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
2)
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
I saw that the level that it asks is the most lower level, so i didn't change anything.
Any hint?
Thank you.