PDA

View Full Version : Change the application user in the environment



Nyphel
22nd June 2007, 14:08
Hi,

I would like my application to be executed by a speific user under Windows.
The "current" user may not have the necessary rights to create a new file, and I would like this action to be performed by "Administrator" user.

Like my I/O operations are performed in a sub-application, I could simply execute this QProcess as an "Administrator" task... For that I can use the void QProcess::setEnvironment ( const QStringList & environment ) function.

The problem is the fallowing : I don't know the keys corresponding.
Using QStringList environment = QProcess::systemEnvironment(), I know that the user name is store in the key "USERNAME". But, in wich key is stored the password ?!

I've the value of the administrator password, but not the key.
As somebody an idea ?

Thanks for your help.

marcel
22nd June 2007, 19:46
No, you cannot do it like that...
And the admin pwd is not stored in the registry :). Come on, not even Windows is not that stupid.

Even if you query the user for the admin password, I'm not really sure if you can use QProcess for launching a process with less credentials than the parent process.

I think you're on the wrong path. Perhaps searching MSDN would provide some results, because I think something like this is not possible without platform API.

If you use Vista, then read something about UAC. I guess it is easier to do it in Vista :). If you need any materials, I'll help you( I think I attached something in an older post )

Regards