I am new here, please let me know if I made an error in my posting.
I'm trying to launch an exe that has a GUI, without needing to log in to Windows 7. I have tried: Windows Task Scheduler, NSSM, SC command, Batch file in startup folder, executable in startup folder,
Also, the SC command has been tried with many different arguments and options. I have tried NSSM, Windows Task Scheduler, and SC command, with the option of using a specific account (not sure about the details), by providing local username and password. All of these have been tried with both batch files and executables. The only purpose of the batch file was to start the executable. I thought maybe this indirect approach would help to an extent, but no there was no difference in trying to launch a program before login.
The key is the GUI, because, for example, I was able to launch a batch file that created a blank text file before logging in (verified by time), using Windows task scheduler, NSSM, and the SC command.
However, if I try to launch, say notepad.exe (start notepad.exe), it won't work. Notepad will not appear as a task, will not have a window, and will not appear as a process. I have tried putting the txt file creation command after the start command in the batch file, and the file is created (so the batch file isn't hanging on the start), but notepad has no trace whatsoever. Some of my peers have also suggested it is a result of the GUI and how it has to have a desktop session.
What has WORKED: 1. Allowing login on bootup without needing password. 2. Executing batch file that would launch program, and then lock the computer. 3. The desktop would flash for only about 1 second.
Problem: This isn't good enough since it is a vulnerability, even if it is only for a split-second.
Found someone who had a similar issue as me, and incorporated it as his solution, but he admits, that it isn't a secure approach. https://serverfault.com/questions/583517/start-program-on-computer-startup-when-nobody-is-logged-on-and-show-the-window-w
There is another avenue that I don't quite understand, that I think could possibly work. Its in regards to the functions LogonUser(), ImpersonateLoggedOnUser(), CreateProcessAsUser(), CreateProcessWithLogonW(). I would be hoping to run it as a service that would be able to "login" and start the program.
Code for creating session:
bool startProcess(string path) {
_STARTUPINFOA info;
info.cb = sizeof(info);
info.lpReserved = NULL;
//The name of the desktop to which we want to connect.
info.lpDesktop = NULL;
//The title assigned to the GUI window.
info.lpTitle = NULL;
//Offset of the window from top left corner
info.dwX = 0;
info.dwY = 0;
//Size of the GUI window that is created.
info.dwXSize = 1000;
info.dwYSize = 900;
//Specifies the nunmber of columns of a console (if applicable) of characters.
info.dwXCountChars = 30;
//Specifris the number of rows of characters of a console window
info.dwYCountChars = 0;
//Specifies the color when opening the new GUI
info.dwFillAttribute = 0;
//Specifies different visual attributes, such as for the cursor.
info.dwFlags = 0;
//This must be zero.
info.cbReserved2 = 0;
//This must be NULL.
info.lpReserved2 = NULL;
info.dwFlags = 0;
//This is NULL because of the value of dwFlags.
info.hStdInput = NULL;
//This is ignored because of dwFlahs.
info.wShowWindow = 0;
//This is NULL because of the dwFlags.
info.hStdOutput = NULL;
//This is NULL because of the value of dwFlags.
info.hStdError = NULL;
PROCESS_INFORMATION ThreadInfo;
bool success = CreateProcessAsUserA(theHandle, path.c_str(), NULL, NULL, NULL, false, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &info, &ThreadInfo);
//lpStartupInfo might be useful in the situation that a display window is not being shown.
threadHandle = ThreadInfo.hThread;
if (!success) {
return false;
}
else {
return true;
}
}
Something that I don't think is as significant, and isn't encountered in most cases, but appears when I'm hacking around:
error encountered : Error 1053 : The service did not respond to the start of control request in a timely fashion
Tried: Cleaning registry Downloading framework NET 4.5.