Is there a way to make putty automatically "close window on exit" from the command line?

The best solution would be to create a custom session in PuTTY (with the "Close window on exit" setting changed) and load that session via the command line, but if you don't have access to the GUI, that's not easy. However, I don't know of any way to specify individual settings via the command line.

If you can edit the registry, however, you can create a session by creating a new key in

HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions

where you can then add values corresponding with the session settings in the GUI. So, if you want to have the window always close on exit, you would add a DWORD value named CloseOnExit containing the value 2. Everything else not specified will stay as the default.

You would then add

-load "session name"

to your command line string, where "session name" is the name of the key you created. Put whatever other command line options after that (such as server, login name, password, etc.) and you're all set.

I've tested this myself, but it's still prudent to back up your registry before any manual editing.

Alternately, there are forks of PuTTY (such as PuTTY Tray) that feature automatic reconnection after an interruption, though I can't vouch for how well they work.

Tags:

Putty