Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Open Ubuntu terminal using batch file on windows with command?

I automate many processes on windows using batch files and putty.

E.g ( login_server7.bat ):

start C:\Users\Jack\Documents\putty.exe -ssh 1.1.1.1 -l user123 -pw "bleh"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How am I able to start an Ubuntu terminal and run a command automatically after opening a file?

Rather than manually opening the ubuntu terminal and typing my commands in?

Cannot see anything elsewhere on this topic. Regards

>Solution :

The executable of WSL is C:\Windows\System32\wsl.exe. You can just type wsl in Windows Command prompt and you will be logged-in to the default WSL instance. Or type wsl -h in order to get the list of all available options. In batch files you can use:

C:\Windows\System32\wsl.exe <your script or command>

Or if you need to run the command as root:

C:\Windows\System32\wsl.exe sudo <your script or command>

Probably more correct way is to use wsl -e -- <command>, but the above works nice for me. Here is more detailed example: Ubuntu 18.04 on WSL cron daemon not running after reboot.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading