Login to Windows via RunDll32.exe with password? - windows

How can I login into a locked windows, using some command in a .BAT file?
I can lock the screen easily from my Java program : RunDll32.exe user32.dll,LockWorkStation
Is there any way to login later automatically (from my running Java program), if I know the password?

No, doesn't work - by design. The login dialog runs in the secure desktop. That's why you see your screen darken when you switch to that desktop.
The goal of the secure desktop is to protect against the sort of manipulation that you are trying to achieve. IOW, even if there was a bug in Windows that would allow it today, it likely would be patched next week.

Related

How to hide terminal shell on server application like Warp in Windows?

I have a small warp server project on Windows that listen to a particular port and do something whenever I send a command to it by REST (for example: POST http://10.10.10.1:5000/print). It's a small client for printing PDF / receipt directly from another computer.
It works. But my problem is when I had to package the whole project, the Rust compiler give me an executable file (.exe). The application displays a terminal window when I run it. I want this terminal to be hidden somehow.
I try to run the program as a windows service (by using NSSM). It doesn't work for me since I had to access the printer. Windows doesn't allow my app to access any devices or any other executable as a windows service. (The reasons are explained here: How can I run an EXE program from a Windows Service using C#?)
So I plan to run my app as a tray-icon application so user can control or close the app. (https://github.com/olback/tray-item-rs)
Unfortunately, I still cannot hide the app's terminal window.
Another solution that I found is hstart (https://www.ntwind.com/software/hstart.html). But I would like to use this as "the last resort" solution since many antivirus/windows defender mark it as a malware.
Do anyone know how to hide or get rid of it ?
After lot of searching, It turns out to be easier than I thought. Just add
#![windows_subsystem = "windows"]
on top of your main.rs file. (for rust > 1.18) and the terminal is gone.
These control the /SUBSYSTEM flag in the linker. For now, only
"console" and "windows" are supported.
When is this useful? In the simplest terms, if you're developing a
graphical application, and do not specify "windows", a console window
would flash up upon your application's start. With this flag, it
won't.
https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute
https://blog.rust-lang.org/2017/06/08/Rust-1.18.html
https://learn.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=msvc-170

Launch my application before the Windows logon screen

In a personal project, I want to display my application before (or above) the Windows Logon, ie just before entering the Windows password.
The application must "hide" the password entry screen. I used to launch an application at Windows startup but this after viewing the Windows desktop.
Is it possible to do this please? Should I create a Windows service that will launch my application?
Thanks for your help
If this is just a personal project on your own machine you could set Windows to autologon and then just run your application like a normal startup shortcut.
A NT service is the only documented way to run code before a user logs on. However, spawning a new process in another session and interacting with the Winlogon desktop and putting yourself on top of LogonUI.exe is going to be a hack.

How to force user to use an application at start of Windows

We have an application that checks if the user's password is expired, and in that case, the user is asked to change its password.
We would like to force to user to change the password before using Windows 7.
The problem is that the user can close the window, kill the process, or simply move the change pwd window on the side, ignore it and continue to work on Windows.
What solution do you recommend to achieve this goal?
We thought of locking Windows while running the change pwd app exclusively, but we don't see how to do this.
Using policies to force running only this application just after Windows login? But where is the expiration check done and how the policies can be set?
Thanks for you advices.

Lock Screen and Prompt for Password

I need to create a program that can lock a Windows screen and prompt for a username and password.
It can be in any language but something without .net would be preferable in case I were to want to run it in an older version of Windows or WinPE.
I need it to not allow any other input in any way until the correct username and password have been put in.
It does not matter is the screen behind the prompt is blacked out or if it shows the desktop but doesn't allow the user to click.
Does anyone have any suggestions where I should begin?
I'm not entirely sure what you're trying to accomplish with this knowledge (sounds rather disruptive to the user imo), but you may be able to use the following knowledge to your advantage:
pressing CTRL+ESC simulates the Windows key
Windows key + L locks the computer

How to unlock Windows lockscreen?

How can I unlock the windows lockscreen with Delphi? I didn't found anything on Google or Stackoverflow. I already tried to enter my password using keybd_event but it seems like the events dont work on the lockscreen.
You cannot unlock the lock screen programmatically from user space. That is by design.
OK, let's clarify that. Using documented APIs, you cannot do this. You need to reverse engineer undocumented APIs as #Remko has done for his SasLibEx product.
Remko Weijnen has very interesting projects in this direction. He has released a command-line tool (Winstation Locker) which is capable to unlock local/remote Windows XP station, without knowing the password of the user who has locked the computer.
For Windows Vista and later he has developed SasLibEx** library which can unlock even specific terminal services sessions, again without username/password.
Both methods require you to have Administrative privileges/account at the destination computer.
PLEASE NOTE, all these tools use nasty hacks that may be considered illegal, inappropriate, intolerant or criminal(?). It should be discussed with your Clients/Employer and should be used with caution!
** SasLibEx is a commercial product
Steamlink (a piece of hardware that allows you to stream your steam games to a big screen) currently has an issue, that if your screen is in a different part of the house, in order to play you need to walk to your PC unlock it and then walk back to your big screen.
In order to make it less painful, people in the community came up with this script:
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console" 2> UnlockErrors.log
It can unlock your PC remotely. You can call tscon.exe from Delphi to emulate the same.
This actually can be done using powershell, psexec and windows onscreen keyboard. While a program cannot send input to winlogon, the windows osk can, and sure enough a program can send input to osk.
NOTE: The following is a remote solution.
As far as i know, Keyboard events wont work on lock screen unless you switch from Default Desktop to Winlogon desktop(Desktop referring to a container of all activities)
[Background]
Default desktop is the one you use when reading this post.
Winlogon would be the one that is set as active when you press Ctrl+Alt+Del
[XP]
You would need to Switch from Default to WinLogon Desktop[Check reference] and then you would be able to unlock machine by getting Window handle for Unlock Computer
IntPtr windowHandle = (IntPtr)FindWindow(null, "Unlock Computer");//Getting Window handle
Send username and password to respective edit boxes.
Reference
http://www.codeproject.com/Articles/16197/Remotely-Unlock-a-Windows-Workstation
[Win7]
Run tsdiscon.exe from remote. Not sure how this works; but for me, it unlocks the Locked Screen.

Resources