8

I need to launch putty through command line argument programmtically. I am doing this using the command as:

C:\Programs\putty.exe -ssh -l root -pw password hostname

which works fine.
Now I want to open the session with changed title of my choice. I know this can be done using

Disable remote-controller window title changing
and setting
Window title
But is there any way to pass these parameters as command line argument while launching?

6
  • 1
    As far I know that is not possible, you can do it in the batch file with the TITLE command
    – Josem
    Commented Jun 26, 2018 at 11:15
  • You could create a temporary Saved Session by manipluating the registry, and then -load it... (eww - don't do that). Alternatively, could the remote set the title for you?
    – Attie
    Commented Jun 26, 2018 at 11:31
  • Let the host send a terminal escape string that sets the title? Commented Jun 26, 2018 at 11:31
  • @Gerard H. Pille Can you please post an example? All I want is a putty window that has a title of my choice.
    – gbhadhar
    Commented Jun 26, 2018 at 14:56
  • @ Attie Would prefer not to manipulate the registry. Remote setting the title for me: is there any command that I need to execute post login? Can you please provide an example, would like to try it out through my program in Java.
    – gbhadhar
    Commented Jun 26, 2018 at 15:00

2 Answers 2

13

I was able to get the putty SSH terminal session to change its title by following a few steps as I found in the Set PuTTY's window title to name of loaded session post on Server Fault.

Change Window Title of Putty Terminal Session

  1. From the PuTTY app go to Session and then define the Host Name, Port, and SSH connection type.

    enter image description here

  2. From Terminal -> Features, then checked the Disable remote-controlled window title changing option.

    enter image description here

  3. Go back to Session and then in Saved Sessions type in the hostname or session name you want that host to be defined as and press Save. You should not see that session in the list.

    enter image description here

  4. Now you can load the SSH session with PuTTY via the command line from that same PC but append the -loghost "My Title" for the title of the terminal window to have that value in it instead.

Command

C:\Programs\putty.exe -load "Hostname" -ssh -l root -pw Password Hostname -loghost "My Title"

enter image description here


Further Resources

5
  • thanks for your answer. I tried both the ways. Observed that with login successful, the title of the putty window becomes root@hostname:~. I am required to execute this command from a Java program, and I tried running from both program and a batch file, resulted the same. Am I missing something?
    – gbhadhar
    Commented Jun 26, 2018 at 14:48
  • "Another example" has an unpair number of double quotes. Commented Jun 26, 2018 at 19:18
  • Almost there! As I mentioned in the question, performing the manual step of selecting "Disable remote-controlled window title changing" works, but I am launching Putty through another program and I don't have the option to manually select this checkbox. "-loghost" is changing the title before login, but once login is successful, title becomes "root@hostname:~". Is there any parameter to pass in the command itself to do this job? An equivalent of "Disable remote-controlled window title changing"?
    – gbhadhar
    Commented Jun 27, 2018 at 4:06
  • I am using Ubuntu, can be IPv4 or IPv6 or dual
    – gbhadhar
    Commented Jun 27, 2018 at 4:25
  • 1
    With the input from @Attie, I modified the registry for Default Settings for key NoRemoteWinTitle, resulting not to have remote title for any putty session. Then executed the command as follows to get the desired result: <pre> <code>CMD /C "start "HA-Primary" C:\Programs\putty.exe -load "Default Settings" -ssh -l root -pw password hostname -loghost "HA-Primary"</pre>/code> Appreciate all your help and would welcome any comment for further improvement.
    – gbhadhar
    Commented Jun 28, 2018 at 8:14
1

what i do to make my life easier,

1) use mtputty application. 2) edit mtputty.xml file to create/import sessions 3) Under Tools menu > settings > general > check - "show display name", instead of "Replicate Putty window caption"

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .