'Start a session in MobaXterm from batch script

When I had Windows 7, the following batch command opened MobaXterm, and inside, it opened a new tab (in addition to the home tab) that connected to a VM ('linux-server'):

start "" "C:\Program Files (x86)\MobaXterm\MobaXterm.exe" -newtab linux-server

Now, in Windows 10, the command does not work well. It opens MobaXterm, but does not open a session to the VM.

I tried to run the command from command-line, the result is the same.

My requests are:

  • Opening a session to the VM in MobaXterm using batch command (the "home tab" that was opened in the past is unnecessary)
  • I use private key to connect this session, for some reason, Moba does not save the passphrase for the private key, only the user's password. I would like to save the passphrase as well.

Thanks in advance!



Solution 1:[1]

From the MobaTek Blog

MobaXterm.exe -newtab ["<Command>"]:

This command can be used to start a new tab inside a running instance of MobaXterm (or start a new instance of MobaXterm if no other instance is running) and immediately execute a given MobaXterm command

So you would need to specify a ssh command to connect to your virtual machine.

You could also save the ssh connection (or any other connection type) as a "first level" bookmark and use the bookmark-command instead:

MobaXterm.exe -bookmark "<Bookmark_name>":

This command can be used to start a bookmark by specifying its name.

In your case, the command would look like this, if your bookmark would be called "linux-server"

start "" "C:\Program Files (x86)\MobaXterm\MobaXterm.exe" -bookmark linux-server

Solution 2:[2]

I'm providing example usage for opening mobaxterm with specific command. Below is an example of opening a MobaXterm portable Personal edition in a newtab mode with SSH and a specified username.

MobaXterm_Personal_20.6.exe -newtab "ssh -l username 192.168.1.99"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Nadzri