Solved

command prompt batch file

Posted on 2013-06-06
6
758 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 69

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help Creating a Powershell script 8 64
gawk solution to extract this ? 2 21
Windows server 2008 exchange 3 28
unknown computers in my LAN 12 35
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

730 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