I am using Psexec.exe to execute a script on a remote Windows system. The system is set up to only allow one user to be logged in at a time to prevent interference with testing. However, when I use Psexec.exe to run my script, if I run qwinsta on the remote system (also using psexec), it shows that there are no active sessions, and I am able to remotely log into it.
Is there a way to prevent users from logging in whenever I use Psexec to run my script on the remote system?
Psexec is running as the system. I do not specify a username in the Psexec command. The other users attempting to remotely log in all have different usernames.
Your best option would be to disable and enable remote access as part of your psexec script. You may be able to use these commands to do it.
There is also a registry key you could toggle but I don't know it off hand.
You would just need to remember to go back and enable it if your script fails. You may also find yourself fighting with group policy if remoting is enforced from there.