Solved

command prompt batch file

Posted on 2013-06-06
6
713 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
  • 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 68

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 lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now