473,395 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Run from command line

9
Hi,

i need to execute a bat file.

i go to start->run and type the below line:

cmd /C start "C:/Documents and Settings/Shoby/Desktop/CMTHome\bin\execute.bat"


On doing the above all i get is the command window open.It does not execute the exe...

Can someone help me with it??????
Sep 13 '08 #1
5 2165
JosAH
11,448 Expert 8TB
Hi,

i need to execute a bat file.

i go to start->run and type the below line:

cmd /C start "C:/Documents and Settings/Shoby/Desktop/CMTHome\bin\execute.bat"


On doing the above all i get is the command window open.It does not execute the exe...

Can someone help me with it??????
What exe file? All I see is that you're starting a batch file in the background.
Also type "help start" for an explanation for what you have been doing. And
what was your Java question?

kind regards,

Jos
Sep 13 '08 #2
shoby
9
I have a java code that executes the bat file containing the code to execute the exe. If the batch file is on the desktop the code does not work.ie; when i run the following code, the Command window appears but the batch file does not get executed.

Runtime.getRuntime().exec(cmd /C start "C:/Documents and Settings/Shoby/Desktop/CMTHome\bin\execute.bat");



Any suggestions on how to solve this?
Sep 14 '08 #3
JosAH
11,448 Expert 8TB
I have a java code that executes the bat file containing the code to execute the exe. If the batch file is on the desktop the code does not work.ie; when i run the following code, the Command window appears but the batch file does not get executed.

Runtime.getRuntime().exec(cmd /C start "C:/Documents and Settings/Shoby/Desktop/CMTHome\bin\execute.bat");



Any suggestions on how to solve this?
If you're using backslashes in that String you'd better double them; as in:

Expand|Select|Wrap|Line Numbers
  1. Runtime.getRuntime().exec(cmd /C start "C:/Documents and Settings/Shoby/Desktop/CMTHome\\bin\\execute.bat");
  2.  
kind regards,

Jos
Sep 14 '08 #4
rajujrk
107 100+
Better use the ProcessBuilder class to execute or open all file formats with the relevant open with application.
Sep 14 '08 #5
chaarmann
785 Expert 512MB

Runtime.getRuntime().exec(cmd /C start "C:/Documents and Settings/Shoby/Desktop/CMTHome\bin\execute.bat");

Any suggestions on how to solve this?
In addition to what Jos has said, this source code would not compile anyway.

there are double quotation marks missing in front of "cmd", and the quotation marks that you need inside the string because of the space in the folder name should be escaped this way: \"
And then I would not mix Unix and Windows path separators (normal slashes and backslashes) in the pathname. And I would not even hardcode them, but use File.SEPARATOR instead.

And why are you using "cmd" inside? I mean opening a shell that again opens a shell to execute your batch file, instead of executing it directly within a single shell?

I mean if only one window opens and then nothing happens then the problem could be that the "cmd" is not found by the system and therefore the second shell does not open. Remember that "cmd" is a file in the windows system directory and its name is "cmd.exe". So either the path is missing to this file (check the environment variable PATH or better: just give the whole path), or windows does not know what to do if you just give "cmd" without extension ".exe". So instead of using "cmd", try to use something like "c:\\windows\\system32\\cmd.exe". (Or better, don't use it at all and execute .bat file directly.)
Sep 15 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ever Olano | last post by:
Hi. In the docs, it says the command-line executable (that allows you to run PHP scripts on your console as opposed to inside the web server) was introduced in 4.3.0. But I was told by someone...
8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
7
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the...
4
by: lkrubner | last post by:
I'd like to write a PHP script to be used from the command line on a Unix machine. I'd like for the script to put together a string, turn it into a web page, print it, then return control the...
5
by: randyelliott | last post by:
Good Day, I have a MS Access (Access 2000 now upgraded to 2003) database that tracks customer information. One function of this database is to create an encrypted license file for our software,...
34
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: ...
3
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. ...
4
by: Bit byte | last post by:
I have a project that I normally build (without problems) from the DevStudio IDE. However, I have embarked on automating all my builds (this test project being one of several). The project...
2
by: Jim | last post by:
Hello, I need a program that will traverse a directory tree to ensure that there are unix-style line endings on every file in that tree that is a text file. To tell text files from others I...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.