Testing the installation procedure of a program that requires administrative privileges

I am trying to write an automated test to make sure that the installer for my program is working fine.

The program can be installed for all users (requires admin privs) or for the current user (does not require admin privs). The program can also automatically fail itself, which in some cases requires administrator rights, and in some cases does not.

I’m looking for a way that I can have an automatic test, click “Yes, allow” in the UAC dialogs so that I can write tests for all different scenarios on many different operating systems so that I can be sure when I make changes to the installer that I didn’t break anything.

Obviously, the installation process itself cannot do this. However, I control the full machine and can easily start some kind of daemon process with administrator privileges so that the test program can connect to the socket to request "click ok in UAC now."

+3
source share
4 answers

I really figured out how to do this by looking at a similar question about UAC. Here is what you can do:

  • Write a service that works like SYSTEM.
  • Open the process token of the winlogon.exe instance running in the login session.
  • Use this token to start an auxiliary process on the Winlogon desktop through CreateProcessAsUser.

, SYSTEM Winlogon (). - IPC . EnumDesktopWindows UAC. , ; "" "", , . , Windows 7 32-bit; , UAC Vista, .

, ; , .

EDIT: , FindWindow(), "", BM_CLICK; UAC , .

+4
0

, , - VMWare / vmware sdk.

0

Remote desktop to it or run it as a guest virtual machine (using Virtual PC or any other, just do not load it). This is also the best way to take a screenshot or video from a UAC prompt.

0
source

Source: https://habr.com/ru/post/1745259/


All Articles