Second command prompt not closing after installation completed

Ravi Kumar

New Member
Joined
Jun 29, 2016
Messages
4
Am creating a batch script to install ruby gems along with some other automation. But when "gem install <gemname>" command triggered its opened new command prompt to install and its not closing it as soon as gem installation completed.

I tried below things as well which didn't help me,

START /WAIT /b gem install --no-rdoc --no-ri json
START /WAIT gem install --no-rdoc --no-ri json /b

Can someone help me out to get the additional command prompt closed as soon as installation completed
 


Solution
You should look into the cmd /k option.

cmd /k gem install --local --quiet --no-rdoc --no-ri ffi-1.9.10-x86-mingw32.gem ffi-1.9.10-x64-mingw32.gem >> install.log
Can I ask why you're even using the START command to begin with?
 


Yeah you shouldn't need Start at all. If you want to explicitly close the cmd just add exit at the end of the batch file
 


Okay. I tried without using START and below the current script.

@echo OFF
echo Installing Gems
gem install --local --quiet --no-rdoc --no-ri ffi-1.9.10-x86-mingw32.gem ffi-1.9.10-x64-mingw32.gem
echo Completed Gems installation



Once the gem installation completed am not getting the message "Completed Gems installation". Below is the output of this script,

c:\temp>gem_install.bat
Installing Gems
Successfully installed ffi-1.9.10-x86-mingw32
Successfully installed ffi-1.9.10-x64-mingw32
2 gems installed

c:\temp>
 


Last edited:
I mean... your "2 gems installed" message is just as good as "Completed Gems installation"

You can also redirect text to a file in batch scripting then use the type command to display it.

The only thing I can think of as far as your second echo not working correctly is that the gem command is altering the command prompt space somehow therefore breaking it. You could try an "ECHO ." after it which might mitigate the problem..

Or you can try something like this...
@echo OFF
@echo Installing Gems >> install.log
@gem install --local --quiet --no-rdoc --no-ri ffi-1.9.10-x86-mingw32.gem ffi-1.9.10-x64-mingw32.gem >> install.log
@echo Completed Gems installation >> install.log
@echo Installation results:
@type install.log
 


Hmm I also suspect gem command is altering the command prompt behavior. I tried the method which you suggested and getting the same result only.

Below is the output I got in install.log file.

Installing Gems
Successfully installed ffi-1.9.10-x86-mingw32
Successfully installed ffi-1.9.10-x64-mingw32
2 gems installed
 


You should look into the cmd /k option.

cmd /k gem install --local --quiet --no-rdoc --no-ri ffi-1.9.10-x86-mingw32.gem ffi-1.9.10-x64-mingw32.gem >> install.log
 


Solution
Back
Top