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"
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.