Solved

command prompt batch file

Posted on 2013-06-06
6
765 Views
Last Modified: 2013-06-07
How can I run multiple commands from a batch file

This works
@echo off
cmd.exe /K "cd C:\Program Files (x86)\Java\jre7\bin"


The last line in this does not.
I tried adding double quotes etc...
Any ideas?

@echo off
cmd.exe /K "cd C:\Program Files (x86)\Java\jre7\bin"
cmd.exe java -cp m5.jar;m5-data-objects.jar;webservices-rt.jar;log4j-1.2.13.jar
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
Aeriden earned 500 total points
ID: 39227205
I am not sure why cmd.exe is being called.

Instead, create a batch file (e.g. mybatch.bat) with the following:

@echo off
cd "c:\program files (x86)\Java\jre7\bin"
java -cp m5.jar;m5-data-objects.jar;webservices-rt.jar;log4j-1.2.13.jar

Then call mybatch.bat from a command prompt (for example).
0
 

Author Closing Comment

by:lrbrister
ID: 39227220
Wow!
Was I over thinking that or what?
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39227396
Be aware that
  cd "c:\program files (x86)\Java\jre7\bin"
just changes the current working directory on drive C:, but does not change to drive C:. Use the /D parameter to make sure you also change drives:
  cd /d "c:\program files (x86)\Java\jre7\bin"
It won't matter in this case, as you are certainly already on C:, but it is a common trap.
0
Don't Miss ATEN at InfoComm 2017!

Visit booth #2167 to see the  new ATEN VM3200 32 x 32 Modular Matrix Switch. Other highlights include the VE8950 4K HDMI Over IP Extender, VS1912 12-Port DP Video Wall Media Player  and VK2100 ATEN Control System. Register now with Free Pass Code ATEN288!

 

Author Comment

by:lrbrister
ID: 39228695
Qlemo,
 Thanks for the follow-up
0
 
LVL 9

Expert Comment

by:Aeriden
ID: 39230402
Yes, Qlemo brings up a good point.  I normally would do (and should have caught):

@echo off
c:
cd "\program files (x86)\Java\jre7\bin"
java -cp m5.jar;m5-data-objects.jar;webservices-rt.jar;log4j-1.2.13.jar
0
 

Author Comment

by:lrbrister
ID: 39230414
Thanks guys.  Much appreciated.
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An article on effective troubleshooting
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question