I am trying to run a script which launches a WSL (ubuntu1804) terminal, and then run a bash script in that terminal
.\ubuntu1804.exe;
cd test_directory;
node server.js;
However after the first command the terminal open however, the two other commands aren't executed
.\ubuntu1804.exe by itself opens an interactive shell which PowerShell executes synchronously.
That is, until you submit exit in that interactive shell to terminate it, control won't be returned to PowerShell, so the subsequent commands - cd test_directory and note server.js - are not only not sent to .\ubuntu1804.exe, as you intended, but are then run by PowerShell.
Instead, you must pass the commands to run to .\ubuntu1804.exe via the run sub-command:
.\ubuntu1804.exe run 'cd test_directory; node server.js'
Note: Once node exits, control will be returned to PowerShell.
Related
I have a task I'm using to run the make command for a build process in vscode. I want this command to be run in a specific environment instead of powershell since it has unix like calls in the makefile. I would like to use bash (git bash) or any shell binary instead.
The error I'm getting from the task for reference: The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command make" terminated with exit code: 1.
Thanks in advance
I created a task with the task scheduler in windows 10 to open cmd.exe. it ran successfully like this
But I need to run some commands every time it opens something like this
and automatically runs this command.
this is important that it opens a command prompt first and then runs the command inside the command prompt automatically.
Thanks.
Use /k flag. See cmd.exe /k switch.
If you don't need console window to stay after commands completed use /c flag. You can read more about them with cmd /?
I have a powershell file that I have downloaded from ScriptCenter that allows me to control and query virtual desktops on my machine (https://gallery.technet.microsoft.com/scriptcenter/Powershell-commands-to-d0e79cc5).
Using their example, I can run that ps1 file at the start of my script to use those commands that the script creates. All fine here.
The only issue with this is that when I run my script, it asks to confirm to run it. This is something I don't want my script to do.
To work around this, I tried using the "PowerShell" command with "-ExecutionPolicy Bypass" set. This removes the prompt to approve the script, however it stops the script from being loaded into my scripts session as I can't use any of the commands it make available by running it.
How do I either run the script first, without it prompting, or execute the powershell command so that it is run in the session space of my script so that its commands are available?
Thanks
I am trying to open multiple cygwin terminals and run a .exe file in each of them through octave GUI. I was able to do this in MATLAB, but the exact same code in octave does not work.
Code used :
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_1.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_2.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_3.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_4.sh']);
testtorun_ig1_1 has the command to open a .exe file.
What happens in octave is, initially one cygwin terminal open and runs the .exe file. After the application completes and exits, cygwin terminal closes and opens the next cygwin terminal opens and runs the second .exe files. I want to be able to run 4 cygwin terminals at a time, which is what happens in MATLAB but not in octave
In Octave, dos waits until the external command completes before executing any more commands.
Octave waits for the external command to finish before returning the exit status of the program in status and any output in text.
If you want to evaluate the external commands asyncronously, you should use the system command with the 'async' input argument
id = system('C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_1.sh', 0, 'async')
I have a small problem with my Powershell script.
What do i want:
open CMD via PSEXEC on a remote machine, and work in this "remoteshell" as if i am in front of this machine. There is a commandline tool which i'd like to run, which requires user input after its started (it runs a own "shell")
What the problem is:
i utilize PSEXEC 2.11 with the following command
.\PSEXEC \\$Global:Endpoint -s -accepteula cmd
Cmd gets started as expected.
When i enter the name of the tool (lets call it tool.exe) the inital screen is loaded. But when the shell appears, nothing happens. I can enter commands but there will be no feedback...
C:\windows\System32>tool.exe
Testing Tool V1.0
Command? >
Then nothing can be entered anymore...
I even cannot stop it by pressing CTRL+C. I need to close the application window to force it to close. :(
Any ideas? Are there programs which cannot run in "user interaction" mode?
For reasons, it cannot run as a window visible on the remote endpoint. It needs to run silent.