How to run a .bat file with string arguments?
Hi,
I have a problem in running a .bat file with string arguments
- the file is XPathOverlap.bat with 2 stringarguments like: "/a" and "//a"
- the cmd: c:\Downloads>XPathOverlap "//a" "/a" works fine.
- here is my code:
public static void test(){
try{
String loc1 = "//a";
String loc2 = "/a";
String[] cmdarray = {"c:\Downloads\XPathOverlap", loc1, loc2};
Process p = Runtime.getRuntime().exec(cmdarray);
p.waitFor();
System.out.println("Exit Value: "+p.exitValue());
//code to print command line replies
InputStream cmdReply = p.getInputStream();
InputStreamReader isr = new InputStreamReader(cmdReply);
BufferedReader br = new BufferedReader(isr);
String line = null;
while((line=br.readLine())!=null){
System.out.println(line);
}catch(Throwable t){
t.printStackTrace();
How can i run this bat file with 2 string arguments?
Hi,
thanks thats good and helpfully
so this code works:
String loc1 = "\"/a\"";
String loc2 = "\"//a\"";
String path = System.getenv("MuSatSolver");
String[] cmdarray = {"cmd.exe","/C",path+"XPathOverlap.bat", loc1, loc2};
Process p = Runtime.getRuntime().exec(cmdarray);
p.waitFor();
System.out.println("Exit Value: "+p.exitValue());
InputStream cmdErr = p.getErrorStream();
InputStreamReader isrErr = new InputStreamReader(cmdErr);
BufferedReader brErr = new BufferedReader(isrErr);
String line2 = null;
while((line2=brErr.readLine())!=null){
System.out.println("Error: "+line2);
but now i have another problem, this is the output:
Exit Value: 0
Error: java.lang.NoClassDefFoundError: fr/inrialpes/wam/treelogic/_xml/XPathOverlap
Error: Exception in thread "main" The Exit value is 0, so the process terminates normally.
I have tested this bat file in cmd and there it works correctly.
Why do i get this error message?
Similar Messages
-
Hi, my program needs to use an outside batch file command, for instance, its name is "generateXML", its syntax is
[command prompt] : generateXML sourceFile.dtd XMLFile.xml
I want to include this command into my code so that do that and other things at one go.
ThanksOn Windows 98 try something like this:
Process process = Runtime.getRuntime().exec( "command.com /c generateXML sourceFile.dtd XMLFile.xml" ); -
Sqlbase - how to run a stored procedure with SYSDATE argument
Hi, everyone!
I'm trying to execute a stored procedure :
cstmt = con.prepareCall("{ call PR_MYPROCEDURE(?, SYSDATE-1, SYSDATE) }");
cstmt.setInt(1,1);And i get and SqlException - java.sql.SQLException: prepareCall(): An unexpected character 'S' found.
Is there any way to pass a SYSDATE like argument?the problem that for sqlbase current date function is SYSDATE'sqlbase' the database?
I couldn't ensure that the syntax that you posted looks correct but it seems possible.
That would suggest there is a driver problem.
Best I can suggest is modify the proc so it expects nulls for two parameters and then it creates the expressions that you are passing. Or create java Timestamp values and pass those. -
Run .bat file with arguments?
Hi,
I need to run the .bat file with parameters/arguments in Adode Indesign JavaScript. "File.execute()" executes the file using the appropriate application.It executes the .bat file suceessfully.But I am unable to pass the arguments.I need to execute the command like
Eg : test.bat parameter1 parameter2
var myFile=new File("c:\\test.bat");
myFile.execute();
The above statements works fine. Is it possible to execute the with parameters. Please suggest the solution to above problem.Hi,
let VB start the *.bat. this works for me:
#target InDesign
doTheBat('START "" "C:\\Program Files\\Adobe\\Adobe Photoshop CS5.1 (64 Bit)\\Photoshop.exe"')//Start Photoshop, just a example
function doTheBat ( _data ) {
try
var _file = new File('~/myTmpBat.bat');
_file.open( 'w' );
_file.encoding = 'UTF-8';
_file.writeln ( _data );
_file.close();
//_file.execute();
myVBScript = "Set WshShell = CreateObject(\"WScript.Shell\")\r";
myVBScript += "WshShell.Run chr(34) & \"C:\\Users\\%USERNAME%\\myTmpBat.bat\" & Chr(34), 0\r";
myVBScript += "Set WshShell = Nothing\r";
myVBScript += "\r";
app.doScript(myVBScript, ScriptLanguage.VISUAL_BASIC);
}catch (e){ alert(e);
Good luck
Hans-Gerd Claßen -
Problems running bat file with calls to java programs (.jar)
I created a bat file with calls to jar programs. In each line,
I put a call to the programs with parameters, but bat only
executes the first line and ends execution.
All lines of my bat file must be executed.
What should I do?
Best Regards,
Pedro Felipe
[http://pedrofao.blogspot.com|http://pedrofao.blogspot.com]
[http://viajantesmundo.blogspot.com/|http://viajantesmundo.blogspot.com/]user8730639 wrote:
I realized that the problem isn`t my bat file. I made tests calling another jar files and then all the lines of the batch file were executed. So, the jar file called on my previous bat is finnishing the execution. I verified and the jar apps worked without error.
I would like to know if exists any command in Java that can cause this effect (close a batch), to modify the open source code of the application.Not that I know of.
Is prism a bat file?
If you are invoking bat files from your bat file without using call that would explain it
:: mymain.bat file
:: call the first bat file
call prism.bat arg1 arg2 arg3
:: call the other bat file
call prism.bat arg4 arg5 arg6
:: -
How to call a .bat file from java code?
How to call a .bat file from java code? and how can i pass parameters to that .bat file?
Thanks in advancethanks for ur reply
but still i am getting the same error.
I am trying to run a .bat file of together tool, my code looks like below
import java.lang.Runtime;
import java.lang.Process;
import java.io.File;
class SysCall{
public static void main(String args[]){
String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
//String path="D://Borland//Together6.2//bin//Together.bat ";
Runtime r= Runtime.getRuntime(); //Declare the system call
try{
System.out.println("Before batch is called");
Process p=r.exec(cmd);
System.out.println(" Exit value =" + p.exitValue());
System.out.println("After batch is called");
/*can produce errors which must be caught*/
catch(Exception e) {
e.printStackTrace();
System.out.println (e.toString());
I am getting the below exception
Before batch is called
java.lang.IllegalThreadStateException: process has not exited
at java.lang.Win32Process.exitValue(Native Method)
at SysCall.main(SysCall.java:17)
java.lang.IllegalThreadStateException: process has not exited -
How to run a .bat code?
how to run a .bat code?
I have a code ,batch (.bat) in richtextbox1, and want , to text(code .bat) in richtextbox1 it was launched in the console cmd
without the use of saving a file with this code and run itIn your code, right-click on the word "Desktop". In the context menu, select "go to definition". The object browser opens. You will see other members of the SpecialFolder enum. You can examine these values and read the description below.
One of them is "ProgramFiles". If you pass this value to GetFolderPath, it returns the path of the program files.
Another way: In your code, move the caret to the word "desktop" and press Ctr+J. It will open the same list of enum values. Whenever you select an item in the list, the tooltip should also show a description of the enum value.
Then look at
System.IO.Path.Combine to combine the program files path with the sub folder path. The result will be the full path of the directory. You can call Path.Combine for every path name or file name that you want to add.
Armin -
Hi Experts,
I am trying to implement automatic cache purging every day at specified time and i created txt file with SApurge All cache() and created bat file with nqcmd -q Analyticsweb -u username -p password -s (txt file location).
Now i want to run this bat file daily at specified time with out executing manually may i know how to run the batch file at specified time .
Thanks,There is task type as command in workflow manager if you want you can go for that during the load
nqcmd -d "AnalyticsWeb" -u Administrator -p Administrator -s "D:\PowerCenter8.1.1\server\infa_shared\SrcFiles\1_BIPurgeCache.txt"
Check these urls
http://docs.oracle.com/cd/E12103_01/books/AnySched/AnySched_Scripts3.html
http://deliverbi.blogspot.com/2011/12/purge-all-cache-from-dashboard.html -
I am trying to run a bat file which also runs a ksh script;The bat file is a bit tricky because it contains the following:
set PATH=%CYGWIN_PATH_AGL%\bin;%PATH%
%NUTC_PATH_AGL%\sh -c a.ksh %1 %2 %3 %4 %5 %6 %7 %8 %9
These lines call Nutcracker, which is a UNIX-simulator on WindowsXP;
When I double-click the bat file,it runs ok...but:when i try to call it with:
try
Runtime runtime = Runtime.getRuntime();
String[] cmd =
{"D:/Documents and Settings/stud6/jbproject/untitled3/a.bat"};
Process p =runtime.exec(cmd);
catch(Exception ex)
ex.printStackTrace();
...it does absolutely nothing!
Running an usual bat file also works fine;
Please help me!Thanks in advance!...it does absolutely nothing!It does something, just not what you thought it would. It probably aborts with a "bad command or filename", since you need the command shell to run a batch file.
-
Running a Bat file from a stored procedure
This is part II of Re: Need to run bat file from application express
I thought I would open a new thread
I thought I had this fiqured out but it still doesn't work
1) I granted CREATE EXTERNAL JOB to my user
2) startup the OracleJobScheduler Service
3)
create or replace
PROCEDURE RUN_OS_COMMAND(p_cmd IN varchar2)
is
v_job_exists pls_integer:=0;
begin
select count(1)
into v_job_exists
from all_scheduler_jobs
where job_name='JAVA_EXE';
if v_job_exists>0 then
dbms_scheduler.drop_job(job_name =>'JAVA_EXE');
end if;
dbms_scheduler.create_job
( job_name =>'JAVA_EXE'
, job_action =>p_cmd
, job_type =>'executable'
, enabled =>false
, auto_drop =>false
, start_date =>systimestamp
dbms_scheduler.run_job(job_name =>'JAVA_EXE');
end;test.bat is del test.csv
I run this
begin
RUN_OS_COMMAND('C:\temp\test.bat');
end;
/ anonymous block completed
It runs with no errors but does not run the bat file... what am i missing, thanks DougLLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\wblincoe\Application Data
CLASSPATH=.;[ORACLE_HOME]\jdbc\lib\ojdbc6.jar;c:\myjar\xdocore.jar;c:\myjar\i18nAPI_v3.jar;c:\myjar\xdoparser.jar;c:\myjar\xmlparserv2.jar
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=WBLINCOELT
ComSpec=C:\WINDOWS\system32\cmd.exe
DEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\wblincoe
LDMS_LOCAL_DIR=C:\Program Files\LANDesk\LDClient\Data
LOGONSERVER=\\03N-DAYT-DC01
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\OraHome_1\jre\1.4.2\bin\client;C:\OraHome_1\jre\1.4.2\bin;C:\app\wblincoe\product\11.1.0\db_1\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PERL5LIB=C:\oracle\product\10.2.0\http_1\sysman\admin\scripts;C:\oracle\product\10.2.0\http_1\perl\site\5.6.1\lib;C:\oracle\product\10.2.0\http_1\perl\site\5.6.1;C:\oracle\product\10.2.0\http_1\perl\5.6.1\lib\MSWin32-x86;C:\oracle\product\10.2.0\http_1\perl\lib\5.6.1;C:\oracle\product\10.2.0\http_1\perl\lib\5.6.1\MSWin32-x86;
PHPRC=C:\Program Files\PHP\
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f02
ProgramFiles=C:\Program Files
PROMPT=$P$G
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\wblincoe\LOCALS~1\Temp
TMP=C:\DOCUME~1\wblincoe\LOCALS~1\Temp
USERDNSDOMAIN=CACI.COM
USERDOMAIN=CACI
USERNAME=wblincoe
USERPROFILE=C:\Documents and Settings\wblincoe
VSEDEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
windir=C:\WINDOWS -
Trying to run a bat file from oracle
I have followed these steps, see bottom for results, everything is valid but the bat file does not run???? PLease need your help. Doug
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "getbatx" AS
class getbatx //class pdfopen
public static void execmd(String c) //main function
try
System.out.println("Executing:" + c);
Runtime.getRuntime().exec("C:\\WINDOWS\\system32
cmd.exe /c "+c);
System.out.println("Executing:" + c + " ...done");
} catch (Exception e) //catch any exceptions here
System.out.println("Error" + e ); //print the error
CREATE OR REPLACE PROCEDURE host_command2 (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'getbatx.execmd (java.lang.String)';
/Then as sysdba I put in in the following.
exec dbms_java.grant_permission( 'CAPRS', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' );
EXEC Dbms_Java.Grant_Permission('CAPRS', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC Dbms_Java.Grant_Permission('CAPRS', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');Then I make the call.
SET SERVEROUTPUT ON SIZE 1000000
CALL DBMS_JAVA.SET_OUTPUT(1000000);
BEGIN
host_command2 (p_command => 'c:\mybook.bat');
END;
/***** I run this, it completes but does not run the bat file and there is no error message
SQL> BEGIN
2 host_command2 (p_command => 'mybook.bat');
3 END;
4 /
Executing:mybook.bat
Executing:mybook.bat ...done
PL/SQL procedure successfully completed.Yes it should open a dos box, but you forgot to add the .bat file witch you like to run: String[] command = {"cmd", "/c", "start", "c:/Batch files/Cardiobackup/cardiobackup_v1.4"}
-
How to run a batch file as windows Nt service
Hi friends
I want to know how to run a batch file as windows NT service.
I got some information in the following link
http://support.microsoft.com/kb/q243486/
I tried it but i want to know what we need to include in Autoexnt.bat
And one thing i need Instexnt.exe file. I cannot find tht file.
Please search tht file and send me tht file or else send the link in which this file is present
Please give me reply fast.its very urgent.
Thanks in advance.Hi,
My aim is to run a MS-DOS Batch file, that I created to run a Java Prgram.
I need to call the Batch File from the Oracle Procedure, Also I may need to change the content of the Batch File (Argument to the Java JAR File ).
I can keep the JAR FIle either in the Oracle Server or in the Application Server.
The Java program is to convert XML Format FIle to PDF and MS Word format.
Oracle Version : 10g 2.0.1.0.
Thanks in advance
Rizly -
How to configure the .ini file with applet
hai
i am using native methods in that methods they use some ip addresses. when i am using that native methods in applet run the applet using appletviewer tool it works fine but when i am open that applet using html page browser not configure that .ini file data .how to configure that .ini file with browserHi Jay SenSharma,
Thanks for your immediate response.
I saw your URL links, But in your link give the recursive deployment using wlst. But my question is how to configure the oracle weblogic library files into Admin server & Managed Servers by using the wls.jar file through wlst script to create the new domain.
But if create the new domain by using GUI mode then we manually give the admin server port number & managed servers port number and name.
By default the library files are configured with the Admin server in GUI mode. But the Managed server the Library files are not configured with the Managed servers. Then we manually select all the library files to the corresponding managed servers. Then only the applications are deployed into the corresponding managed server.
Regards,
S.vinoth Babu -
How to execute one .exe file with as3 in air ?
Hi
How to execute one .exe file with as3 in air?
I want do this work without fscommand .
plize help me .itsdhanasaraa wrote:
But as this a web application ... By using Runtime i'm getting some probs ..
Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
Ain't gonna happen.
its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
1) it's not "taking more time to execute", whatever that's supposed to mean.
2) there's no other way to execute something. Not that you should every use even that way anyway
3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place. -
How to open a .MOV file with Maverick?
Hello,
I recorded some videos with my iPhone 4S. i sync it then with my computer, but it says that it can not open them. Why? How can i open .MOV files with my computer (running with Maverick 10.9.4) ?Try VLC.
Video Player - VLC
More.
Video Player - Divx
Video Player – Flip4Mac
Maybe you are looking for
-
I'm looking for a Wi-fi app that will display all of the devices currently connected to a wireless network ( my personal network, by the way ). I want to use it to see if there is any unauthorized usage that is killing my bandwidth and also for gener
-
Error While Loggin in Solution Manager 3.2
Hello there!! I have HP-UX, Oracle 9i,Sol MAn 3.2 I have installed Sol Man3.2 on my Dev Server under instance SM1 and system number 00 now when i add this system on my SAP Logon and click on the logon button i get error as connection refused. details
-
I can use {idHtmlTag.location} when I want to know the URL which is shown in an HTML-field. I searched a while how to find the mim-type of the HTML-field. but without results How can I read the mim-type (text/xml or text/html) of the document shown i
-
Always running Hot!!
I am running in the red all the time when recording audio especially vocals. I have tried what seems like everything to change this but nothing seems to work. I'm running Logic 7.2 (of course) with a MOTU Ultralite interface through Rode NT 1 mic. I
-
Trying to connect Time Capsule
I am trying to connect my TC and all I am getting is the blinking amber light. I have loaded the software. I am using a wireless router. Does the use of wireless router require me to do anything unique? I am totally at a loss as to what to do.