What I want is to have a desktop shortcut that will run a script. I've been trying to use batch and Python, but I don't really care what language if it works. I need the script to open a bash shell (Windows Subsystem for Linux) and execute simple commands while keeping the shell open. At first, I thought this would simple, but now I'm questioning if it's even possible. I made a simple batch file that would get as far as opening bash and keep it open, but the test command I put in didn't make it to the shell. (I didn't really expect it to but I can't think of a good way to do this, so I've just been trying random stuff). Here is the batch file I used:
bash
cowsay test
PAUSE
After this, I tried using a Python script to open bash and run a shell script that would keep the shell open and execute commands. Here is the Python script:
import os
import time
os.system("start /wait bash /c {./test.sh}")
while 1:
time.sleep(2)
For some reason, this gives an error saying it can't find bash. This isn't really for a project or anything. It's actually for a friend's computer as kind of a joke, but I would really like to know if this is possible. If anyone has any ideas how this could work, I would appreciate it because I'm out of ideas and can't find any other similar questions.
bash -c ‘cowsay test’bash_path = os.path.join(os.environ['SystemRoot'], 'SysNative', 'bash.exe').subprocess.Popen, with stdin, stdout, and stderr redirected to pipes and two dedicated reader threads, one for stdout and the other for stderr. Do not useshell=Trueor a batch script; CMD doesn't need to be involved with this in any way.