Bonjour,
Je lance sous Windows 7 en C++ une application (toto.exe par exemple) via la commande :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| // Start the child process.
PROCESS_INFORMATION pi = { 0 };
STARTUPINFO si = { 0 };
si.cb = sizeof(si);
if(!CreateProcessA(
NULL,
"MonFichier.exe", // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
TRUE, // Set handle inheritance to TRUE
CREATE_BREAKAWAY_FROM_JOB,
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
// error
} |
Le problème est que j'ai le code de retour 5 de la fonction CreateProcessA qui veut dire que je n'ai pas les droits d'accès.
En effet, MonFichier.exe est situé dans un répertoire qui n'a pas les droits d'écriture (seulement en lecture et exécution).
Ce que je ne comprends pas, c'est que si je la lance via le code suivant :
int ret = system("MonAppli.Exe");
et bien ca marche !
Il faut noter que je lance mon application C++ (toto.exe) en mode admin à partir d'une session non admin.
Je dois absolument utiliser la fonction CreateProcess... 
Avez vous une idée ?
Merci
Partager