windowswindows-subsystem-for-linuxbatch-processing

Run multiple commands using wsl


I have some scripts on my home folder that I would like to run from command line, actually from the task scheduler, but I don't find the way to do so.

I have tried

wsl -u Ubuntu -u jlanza "cd /home/jlanza/bin && ./myscript && ./myotherscript"

but it doesn't work.

How can I concatenate the execution of several commands under the same session?


Solution

  • C:\Windows\System32\wsl.exe -d Ubuntu -u jlanza sh -c ". ~/.profile && script-jlanza.sh"
    

    This way I load my own own profile and then I'm able to run the commands.

    The option is just to run sh or any shell and then execute the commands you'd like within that shell. The other answer is also valid, but I like mine most, as I'm able to use the user profile (path, aliases, etc.)