Running VSCode from batch file stops execution - batch-file

I'm trying to open two VSCode projects from a batch file, and then close the batch file and let the VSCode run.
Tried several methods:
This does not close the batch file, and if I close it by my self, VSCode terminates:
start "" "C:\Program Files\Microsoft VS Code\Code.exe" c:\project1
start "" "C:\Program Files\Microsoft VS Code\Code.exe" c:\project2
exit
This one opens two cmds, each one opens VSCode and then terminates, but often it also holds and does not close for some reason:
start cmd /c "code c:\project1 && exit"
start cmd /c "code c:\project2 && exit"
Simply running VSCode sometimes holds the execution of the next commands altogether:
code c:\project1
code c:\project2
.
. <-- Next commands don't run
.
So how should I open VSCode in a way that will not stop the execution and will not depend on the terminal remaining open?

I know this topic is more than 2 years old now, but I was facing this problem right now and just found out the solution.
Try calling code.exe directly instead the code.cmd that is in system path.
"%localappdata\Programs\Microsoft VS Code\Code.exe" C:\project1
"%localappdata\Programs\Microsoft VS Code\Code.exe" C:\project2
exit

Related

Exit CMD after batch file executes

So I tried exit and I tried putting a 2 second delay before exit but neither worked. After the bat file successfully runs, the CMD window will stay on.
I did notice however that a CMD window pops up and disappears right away and then the empty CMD window just stays there. (It's like there are two CMD windows)
#echo off
cd C:\Program Files\obs-studio\bin\64bit
"C:\Program Files\obs-studio\bin\64bit\obs64.exe" --collection Replay, --profile Replay, --scene Scene, --startreplaybuffer --minimize-to-tray
exit
EDIT: Also removing the cd line doesn't make the batch file work. I'm not sure why.
The window doesn't close because calling an app directly will tell the batch execution to wait for the app to close before running the next line. Use Start instead. So your batch will be :
#echo off
cd C:\Program Files\obs-studio\bin\64bit
start "" "C:\Program Files\obs-studio\bin\64bit\obs64.exe" --collection Replay, --profile Replay, --scene Scene, --startreplaybuffer --minimize-to-tray
The exit is superfluous since after the end line it should close anyway. By the way if you're just looking to create something to click/call for launching OB studio with those parameters, using shortcut should be enough (put C:\Program Files\obs-studio\bin\64bit on Start In and write the whole command and parameters on Target)

Jenkins job stuck after command start

I have a problem in my jenkins job and I isolated into one command. So I created another separate job to try to fix it.
So in this job, called "teste" I only have one single command:
start cmd /k call "C:\Program Files\myDir\myBat.bat"
This opens a separate cmd window running my bat file, which should keep running "forever".
But the problem is when I do it, my jenkins job keeps stuck into a "exit 0" operation that I have no idea from where it came from.
Thats the console:
[EnvInject] - Loading node environment variables.
Building remotely on Machine01 in workspace C:\workspace\teste
[teste] $ cmd /c call C:\...dir\jenkins.bat
C:\workspace\teste>start cmd /k call "C:\Program Files\myDir\myBat.bat"
C:\workspace\teste>exit 0
Then it keep stuck at that point.
Example of myBat.bat content:
echo hi
pause
There's any way to make this call in another window without waiting for its finish?
I solve my problem changing the way I was calling my other .bat, calling it through powershell. But since I was from a bat file, I used the command to send a powershell command, calling my other bat file.
Also, I've added another line changing the jenkins BUILD_ID to a fake one, so it doesn't kill it.
So I changed from this line:
start cmd /k call "C:\Program Files\myDir\myBat.bat"
To this :
set BUILD_ID=dontKillMe
powershell -Command "Start-Process 'C:\Program Files\myDir\myBat.bat'"
I hope it helps someone someday.

Starting multiple files through batch file

I am trying to write a batch file which when invoked through cmd would launch 3 programs consecutively. Here is what I have so far:
cd C:\Program Files\CPUID\CPU-Z\
cpuz.exe
cd "C:\Program Files\Core Temp\"
"Core Temp.exe"
cd "C:\Program Files (x86)\EVGA Precision X\"
EVGAPrecision.exe
The problem is that when I execute this batch file it launches the first program and then simply pauses. Only when I close the first program does it go on to the second command. Keep in mind that each of these programs require permission from the user to run through the "Do you want to allow the following program to make changes to your computer?" thing.
The ideal scenario is to have all program launch at the same time with out prompting for permission, but if that is impossible, I'm fine with clicking "Yes" for each one of them as long as they still launch consecutively and I don't have to close each program.
This should do what your looking for:
start "" "C:\Program Files\CPUID\CPU-Z\cpuz.exe"
start "" "C:\Program Files\Core Temp\Core Temp.exe"
start "" "C:\Program Files (x86)\EVGA Precision X\EVGAPrecision.exe"

Cmd window to close after opening process with .bat

I'm new with batch file and the code I'm using I had to find but it always opens cmd but doesn't close it after the program is open. I'm aware that it doesn't close because it's a window process and cmd doesn't close until after the window is closed. I would like to to close after it opens the window. Here is the code:
"C:\Program Files\Java\jre7\bin\javaw.exe" -Xmx1G -Xms1G -jar "Minecraft_Server.exe"
I've used many different ways close it like putting Exit at the end or putting cmd /c in front but that didn't work.
Update
The start command does not seem to work with multiple parameters.
Only solution I could come up with is creating a windowless executable that handles the executing with multiple parameters.
Original answer
I've tested the following and it works because Progra~1 is the a conversion of the Program files folder in oldskool 8 character style:
start c:\Progra~1\Intern~1\iexplore.exe -new -k "http://www.google.com/"
I cannot verify this because I do not have java, but it should work:
start C:\Program~1\Java\jre7\bin\javaw.exe -Xmx1G -Xms1G -jar "Minecraft_Server.exe"
However if more folders start with Progra then it could also be Progra~2, Progra~3 etc. You would have to try what works.

Batch file that doesnt run

I have creted a batch file that I want to run the SetupCodeGroup.exe
When I double click the batch file it doesnt run the exe file. A command prompt opens up but it doesnt run the file. Can someone tell what I missed or what I am missing
C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
type pause on the next line and check whether this executable comes on the command prompt .
try
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup‌​.exe
moreover
start /d "path_to_file_directory" program.exe
is the complete line to execute program and console will not wait to program to exit .
I wonder if this exe requires administrative privileges. Try right-clicking the batch file and running it as administrator.
#echo off
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup‌.exe
echo Done
pause
try that if that dose not work then your computers privleges are messed up, i ran into the same problem on my cousins computer.

Resources