Installer Testing: Automating Windows Logon


Anamnesis
As planned, I created the service, looked that it can run the command
ping localhost > c:\outping.txt
immediately after rebooting, before entering the system. Replaced ping with my autotest, and nothing worked . Services that can start before the first login are started on behalf of the localsystem system account and cannot be interactive . This means that when running my autotest did not receive a system object that describes the windows displayed on the screen, the so-called desktop. The bottom line is that in the windows system there are three areas in which you can display windows - default (loaded after entering the login / password), winlogon (displays the familiar authentication request) and an invisible area for non-interactive services.
The phrase is so streamlined
Switching between these areas can be done by calling the winapi function SetThreadDesktopI am deliberately avoiding terminology here, lest the article grow into this or quoting the chapter “Sessions, window stations, desktops and window messages” by Mark Russinovich’s book “Sysinternals Utilities. Admin Reference »

“Ok,” the encoder thought, “All you need to do is call one winapi function, start your autotest, and compile it with a static link so that the tester does not suffer from dependencies.
-Ok, - the tester thought, - All in all, now it will be necessary to check the program on all systems to run the prog.
One cannot fail to test a testing tool. However, I didn’t take this path - recently, when I met with obscure things in the behavior of Windows that threatened to invent bicycles, I began to resort to building a query to Google, starting with the last name: Russinovich. It worked now. PSexec will help us out .
Recipe
- Download srvAny and install it in a test environment
- Specify the line in the Application parameter of the srvAny program
"полный\\путь\\к_psexec\\PSexec.exe /x /s /d /accepteula cmd.exe"
.
The / x parameter itself provides startup in the winlogon environment - We will reboot, wait for an invitation to authenticate, if everything is done correctly, the cmd console will loom in the background (on windows 7 it may not loom, but you can switch to it by pressing alt + tab). We will replace cmd with our autotest (for tfs, as I understand it, you need to run a test agent with some parameters) entering the login password \ checking the operation of the new msgina. Done.