How do I target other sessions from a script?

PROBLEM DESCRIPTION or QUESTION


Can I open a new session using “xsh.Session.Open” within a script and then have the rest of the script run in the newly opened session?

RESOLUTION


Xshell scripts include a function to select another session. However, this function is only available when Xshell is in single process mode.

 

  1. In [Tools] - [Options] - [Advanced], check the [Use single-process mode for better performance] option and run Xshell again.

     

  2. In the script, use the xsh.Session.SelectTabName("session name") function after xsh.Session.Open and then run the script.

    xsh.Session.Open("C:\\Users\\test\\Documents\\NetSarang Computer\\7\\Xshell\\Sessions\\test.xsh"); -> In this case, the session name will be test. xsh.Screen.Synchronous = true; xsh.Session.Sleep(1000); xsh.Session.SelectTabName("test") xsh.Screen.Send("help")