I would like to execute, in an automated way, a command on a remote Windows 7 machine. Ideally I do not want to stay connected, but create a persistent session which I can later manually log back into (e.g. with remote desktop). I have been trying with psexec but no dice -- it freezes with various errors, sometimes without a message.
If you don't insist on creating the persistent session on the fly, you can manually create one by logging into your machine via
Step 1: Login to your computer using RDP to create the persistent session. When you close the RDP session, make sure you Disconnect and do not Log Off. Disconnect keeps your session running even when you aren't connected to it; Log Off terminates the session and all programs running within it.
Step 2: Run some kind of SSH server (e.g. OpenSSH) within your persistent session. OpenSSH is free and gets the job done. There are other non-free ones too.
Step 3: Use an