Getopenfilename() used with user personification

Asked

Viewed 74 times

1

I have a process that requires SYSTEM privileges and for this purpose is launched by a service. When this process executes the function Getopenfilename() to open a select file dialog box, I get an error message saying

C: Windows system32 config systemprofile Desktop is not available.

Desktop folders, My Documents etc, when I select them in the dialog box, are associated with the SYSTEM account. This is because the process is running with SYSTEM privileges. Right.

I tried to solve this problem by personifying the application with the function Impersonateloggedonuser(), but the function dialogue box Getopenfilename() is still associated with the system account and displaying the same error messages.

I have also tried with the new API dialog box, the Common Item Dialog, but the same thing happens. The strange thing is that, if the process is personified as user, the function Getusername() returns the correct name of the personified user.

What could be the reason for this?

1 answer

1

Services do not have interactive desktop access by default. I believe it should be created with a specific attribute to be allowed. Try searching for SERVICE_INTERACTIVE_PROCESS.

This help should clarify the restrictions and means of implementing the solution: Interactive Services

  • The service is already servicetype SERVICE_INTERACTIVE_PROCESS | SERVICE_WIN32_OWN_PROCESS. Does not work. By the way, I don’t know if I was clear on the question, but the service is only used to perform another process. This process runs with SYSTEM privileges (because it is necessary to perform some functions). I personify user privileges within the process itself, but the Getopenfilename() function continues to associate to the system account.

  • You are creating the service with these flags SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS?

  • Yes! As I mentioned above.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.