Running VBS from Java

Hi ,
I want ro run a VBS file from Java but i don`t how.
please help
Thanks
Eli

If you want to know whether Java can interpret and execute vb script then the answer is no.
If you want to get the operating system to execute the vb script then the answer is yes.
Look up the Runtime library.

Similar Messages

  • Close a running application from java........

    Hi all
    I have opened an application say MSWORD from my java class using Runtime.getRuntime(), Now on close button i need to close the application and on the save button of the application i even want to save the application from java command
    The question is HOW????
    please reply,
    Thanx,
    Amitt

    can I open the konsole from java??Yes.
    First you must figure out how to do that from the command line yourself. That has nothing to do with java.
    Note that that how you do that MUST account for the fact that the "command line" is actually a shell. Some commands must be run by running the shell as the actual command and then passing the desired command as an option to the shell (the actual command.)
    Again you can google for examples.

  • Running Fop from JAVA program

    Hi all,
    this may be a rookie question....hope you can help.
    I can run Fop (0.18.0) perfectly from the command line. I created a style
    sheet (xsl file), which converts the xml file. On the command line, I input
    the xsl file, the xml file, and state the name for the pdf file.
    Now I'm trying to run Fop from within method in my JAVA program. This
    doesn't seem to work. Here's the code. Can someone tell me what I'm doing
    wrong? Is it okay to run Fop this way? My classpath is set up properly
    (it runs on the command line).
    Here's the code..............Thanks in advance for any help.
    String [] pdfParams = new String[6];
    pdfParams[0] = "-xsl";
    pdfParams[1] = xslFile;
    pdfParams[2] = "-xml";
    pdfParams[3] = xmlFile;
    pdfParams[4] = "-pdf";
    pdfParams[5] = pdfFile;
    org.apache.fop.apps.Fop.main(pdfParams);
    Regards,
    Suryakant.

    When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
    One thing that jumps out at me is that you're calling waitFor() and then trying to read the process' stdout. But waitFor waits for the process to die, so the stream is no longer there when you try to read it.
    See this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How to run Perl from Java

    Hi,
    I have a program written in Perl. I want to run the Perl program using Java. If there is a command which can allow me to call the perl program from Java program, please advise me.
    regards

    The most easy way is to use Runtime class to call "perl" to run your perl script.
    String sCmd = "c:\\yourPerlScriptLoc\\yourPerlScript.pl";
    Process p = Runtime.getRuntime().exec(sCmd);

  • Run sqlldr from Java

    Hi,
    Trying to run sqlldr from a java Runtime.exec() object. Command line looks good and works if you run it by hand on a console/terminal.
    [cmd-line]
    /oracle/product/10.2/bin/sqlldr userid=usr/pwd@SID control=./app/ctl/office-dept.ctl
    [cmd-line]
    So I kick off the java process and it reaches the command and starts to run it...Then the process just hangs. It never returns...There's no progress either as I monitor the database table for records to be loaded.
    JDK 1.6.0
    Oracle 10.2
    Unix AIX 5.3
    [log-file]
    2011-08-25 12:38:30,777 [main] DEBUG the.weekly - hasTaskStatus()...Complete...Return Status [true] for [null]
    2011-08-25 12:38:30,777 [main] DEBUG the.weekly - Running command [ /oracle/product/10.2/bin/sqlldr userid=usr/pwd@SID control=./app/ctl/office-dept.ctl ]
    [log-file]
    Same Java class that is running this command line works with other command line tools, so I'm pretty sure the Java code is OK. The sqlldr logfile gets emptied, but then never gets any output. I get nothing.
    tia,
    adym

    This is solved...turns out my Java class wasn't quite as correct as I wished...
    Had to move my getErrorStream() and getInputStream() readers above the .waitFor() call...
                            // runConsoleCommand( true ); /* wait for the command to finish  */
                            // OUTPUT : Process the command output...
                            while ((lrowLine = getCommandOutput().readLine()) != null) {
                                getLog().debug( lrowLine );
                                // SCAN : test the output for a success state...
                                if ( lrowLine != null ) {
                                    if ( lrowLine.contains(getCommandSuccess()) ) {
                                        lblnDone = true;
                                        lstrResults = "1";
                            // OUTPUT : Process the error output...certain
                            // commands and command tools may route error
                            // and output into the same stream...
                            while ((lrowLine = getErrorOutput().readLine()) != null) {
                                getLog().debug( lrowLine );
                                // SCAN : test the output for a success state...
                                if ( lrowLine != null ) {
                                    if ( lrowLine.contains(getCommandSuccess()) ) {
                                        lblnDone = true;
                                        lstrResults = "1";
                            exitValue = lrunCommand.waitFor();hth,
    adym

  • Run EXE from JAVA program

    Does somebody know whether it is possible to run some program with extension EXE from JAVA program?

    Yes sombody knows. Yes it's possible. Have a look at Runtime#exec.

  • Running javac from java

    I have created a program which generates code that needs to be compiled while running the program. Currently I am doing it using Runtime.exec() but I don't like the dos window that appears. If there is any way to hide the dos window or compile another way, let me know? Thanks
    This is how I am currently doing it:
    String exec = "javac " + Filename;
    Runtime r = Runtime.getRuntime();
    Process p = r.exec(exec);
    try {
    int exitVal = p.waitFor();
    if (exitVal != 0){
    InputStream stderr = p.getErrorStream();
    InputStreamReader isr = new InputStreamReader (stderr);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null)
    Sytem.out.println(line);
    catch (java.lang.InterruptedException ie){ie.printStackTrace();}

    You can do the following:
    1. Use class generation API to generate ready class. But you must care about syntax or VM will generate errors on load.
    2. Use compiler in SDK from Java. Below is my code:
          File classesDir = new File(home, "classes");
          File javaSource = new File(source.getParent(), className+".java");
                new sun.tools.javac.Main(System.err, "javac").
                  compile(
                    new String[]{
                      "-d",
                      classesDir.getPath(),
                      "-classpath",
                      classesDir.getPath(),
                      javaSource.getPath()
                  );where javaSource is file to be compiled and classesDir is a directory where compiler emits classes.
    The first way is faster, but the second is preferred because you can see intermediate sources. Oh, in second case you must have /java_home/lib.tools.jar file in your classpath. Thats all, enjoy :))

  • Running javafx from java without jfx sdk installed

    I need to run jfx application on client's computer(without jfx sdk installation and outside the browser) from a java code.
    I also need to path parameters from java to javafx and to get return value.
    What i did:
    1) put a.html, a_browser.jnlp and a.jar files on the server.
    2 )run javafx application from java by swt.browser.setUrl(server address/a.html)
    To pass parameter:
    I know single option to pass parameter - create a1.html, a2.html ... an.html for each possible parameter value and javafx will read this parameter by FX.getArgument("parameter"). This solution is ok in my case. But i don't know how to return value back to java.
    thank you

    Problem solved. I used
    Context context = FXLocal.getContext();
    FXClassType instance = context.findClass("loginscrean.PlayerAdapter");
    ObjectValue obj = (ObjectValue)instance.newInstance();
    PlayersObserver po = (PlayersObserver)obj.asObject();
    po.RestartPlayersList();
    in java method which was trying to connect and in RestartPlayersList(); I used FX.deferAction(function() {  method content  });
    I dont't know whether it is a right way of doing it but seems to be working.
    P.S. The reason why application hanged was being careless with synchronization which as a result caused a dead lock.

  • Run program from Java

    Hi all,
    I need to run Cygwin (program which executes shell scripts on Windows) from Java,
    and run some script with Cygwin. Is it possible with Runtime.exec() run Cygwin and
    pass them some script to run?

    I also run into the same problem.
    My problem is i want to run Windows Xp's cmdshell throught java and pass it some parameters.
    I know there is a third party jar which can do it.
    So there must be some way,although maybe not too easy.

  • Error while running EJB from java client on JBOSS

    Hi
    As i am new to EJB i have created a helloworld application in ejb which is working fine when i try to call it from servlet but when i try to invoke the same ejb from java client (i.e from diff jvm) on jboss i got the following error:
    javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]]
         at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1399)
         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at com.gl.TestClient.main(TestClient.java:39)
    Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]
         at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:254)
         at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1370)
         ... 4 more
    Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]
         at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:228)
         ... 5 more
    Caused by: java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
         at java.net.Socket.connect(Socket.java:519)
         at java.net.Socket.connect(Socket.java:469)
         at java.net.Socket.<init>(Socket.java:366)
         at java.net.Socket.<init>(Socket.java:266)
         at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
         at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
         at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:224)
         ... 5 more
    Following is my code:
    Home Interface:
    package com.gl;
    import javax.ejb.CreateException;
    public interface testHome extends EJBHome {
         String JNDI_NAME = "testBean";
         public     test create()
         throws java.rmi.RemoteException,CreateException;
    Remote Interface:
    package com.gl;
    import java.rmi.RemoteException;
    import javax.ejb.EJBObject;
    public interface test extends EJBObject {
         public String welcomeMessage() throws RemoteException;
    Bean:
    package com.gl;
    import java.rmi.RemoteException;
    import javax.ejb.EJBException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class testbean implements SessionBean {
         public void ejbActivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbPassivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbRemove() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void setSessionContext(SessionContext arg0) throws EJBException,
                   RemoteException {
              // TODO Auto-generated method stub
         public void ejbCreate(){}
         public String welcomeMessage(){
              return "Welcome to the World of EJB";
    ejb-jar.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <session>
    <ejb-name>testBean</ejb-name>
    <home>com.gl.testHome</home>
    <remote>com.gl.test</remote>
    <ejb-class>com.gl.testbean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    jboss.xml:
    <?xml version='1.0' ?>
    <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
    <jboss>
    <enterprise-beans>
    <entity>
    <ejb-name>testBean</ejb-name>
    <jndi-name>testBean</jndi-name>
    </entity>
    </enterprise-beans>
    </jboss>
    Client code:
    package com.gl;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    public class TestClient {
         public static void main(String[] args) throws Exception{
                   try{
                   /*     Properties props=new Properties();
                        props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                        props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                        props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
                   Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY,
    "org.jnp.interfaces.NamingContextFactory");
    props.put(Context.PROVIDER_URL, "localhost:1099");
                        System.out.println("Properties ok");
                        //env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.HttpNamingContextFactory");
                        //env.put(Context.PROVIDER_URL,"http://localhost:8080");
                        //env.put(Context.SECURITY_PRINCIPAL, "");
                        //env.put(Context.SECURITY_CREDENTIALS, "");
                        Context ctx=new InitialContext(props);
                        System.out.println("context ok");
                        //testHome home = (testHome)ctx.lookup("testBean");
                        Object obj = ctx.lookup ("testBean");
                        System.out.println("ojb = " + obj);
                        testHome ejbHome = (testHome)PortableRemoteObject.narrow(obj,testHome.class);
                   test ejbObject = ejbHome.create();
                   String message = ejbObject.welcomeMessage();
                        System.out.println("home ok");
                        System.out.println("remote ok");
                        System.out.println(message);
                        catch(Exception e){e.printStackTrace();}
    I am able to successfully deployed my ejb on JBOSS but i m getting above error when i am trying to invoke ejb from java client.
    kindly suggest me something to solve this issue.
    Regards
    Gagan
    Edited by: Gagan2914 on Aug 26, 2008 3:28 AM

    Is it a remote lookup? Then maybe this will help:
    [http://wiki.jboss.org/wiki/JBoss42FAQ]
    - Roy

  • Running VBS from a web page

    Hi,
    I am working on a project and I already have the reports created and populated from a Mysql Db using a VBS.
    The question(s)  are:
    1. How to start the DIAdem VBS  script form an HTML page.?
    2. also how to pass a parameter to this script.?
    The scripts  opens a  dialog window with  dropdown boxes.
    When the script is loaded, the passed parameter will be used in a SQL query, which filters the items in the DDown box
    thx

    Hello Mikey!
    Assuming you DIAdem is already running I would recommend to use an OLE interface. The only problem might be the security restrictions of your web page. Try this HTML page (the Query parameter will be in the DIAdem variable T1):
    <html>
    <head>
    <title>Start DIAdem</title>
    <script TYPE="text/vbscript" LANGUAGE="vbscript">
    Sub DoDIAdem
    Dim oDIAdem
    Set oDIAdem = CreateObject("DIAdem.ToCommand" )
    Call oDIAdem.TextvarSet("T1","MyQuery" )
    Call oDIAdem.CmdExecuteASync("ScriptStart('MyQuery.vbs')" )
    End Sub
    </script>
    </head>
    <body>
    <h1><a href="javascript&colon;DoDIAdem()">Start DIAdem Script...</a></h1>
    </body>
    </html>
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • Running scripts from Java user permissions

    I have a web based application running on JBoss application server. It during its processing of certain requests has to call some cshell scripts using Runtime.exec(). Now it seems to be working fine in development environment, however on testing environment it seems to freeze. On further debugging, and digging up the issue it came up that it could be a permissions issue, as certain users have the permissions to run the scripts and some don't.
    The Question therefore would be that, once a script is executed from an app server, which user is used? and in order for the script to be executed who should be granted permissions.
    Thanks in advance.

    Peter__Lawrey wrote:
    When any application starts another application (java or otherwise) it does so as the same user by default.
    The user running the JBoss is the user used.
    This is how all OSes work (to my knowledge)
    Which operating system are you using?Thanks, in that case I have a second question. Is there a way to force a certain user? I mean somebody other than the one who started the app server programmatically?

  • Creating and running JARs from Java programs

    OK, I have been googling and searching, but this is something I cannot work out, so I raelly need some help.
    Basically, I am building a GUI app that would generate, compile and run java programs. And I also want to enable the users to create JARs they can later double-click if they want to run the program.
    I am using Runtime to compile programs and it works just fine. When I click on a button to create a JAR, my application creates one, but when I double-click on it, it can't find main and it exits. Now that is not so much unusual, but I am positive that my manifest file is OK, because when I run the same command from the command line, then I can click on the JAR file to run it.
    So what is the deal here? I mean, why would a JAR file created from the command line run and the one created through a GUI app using the very same command could not find main?
    Any help would be graetly appreciated.

    again, another unanswered question.
    BTW I'l keep bumping these until I get an answer that works. I have been up 3 hours now trying to get this sorted and it's something that netbeans is supposed to do on its own!?!?!?!?!
    Hello, SUN, is there anyone there???
    No, didn't think so.

  • How to run openscript from Java?

    Hi!
    I have recorded a web script using OpenScript. But instead of doing the playback in the OpenScript environment, I want to run the script from regular Java code.
    Does anyone know how to do that?
    Basically what I have tried out, is copying the code from the Java code view in Openscript, into a class in my Java project and imported all the oracle.oats... jar-files into my build path. It compiles fine.
    Then I try to call;
    MyOpenscriptClassInstance.initialize();
    MyOpenscriptClassInstance.run();
    MyOpenscriptClassInstance.finish();
    The initialize fails on a NullPointer on the browser.launch(), so clearly some more setup is needed to get the script running.
    I found one useful tip here How to call openscript from a flat java file about an alternative method, but I do not have oracle.oats.jagent.applications.qos among my jar-files in C:\OracleATS\openscript\plugins, so I am not able to locate the JavaAgentWrapper-class, the ScriptResult-class and the RunParameters-class.
    If anyone could guide me in the right direction, I would be grateful.
    I am running OpenScript version 9.2.0.0 by the way.

    Hi again!
    I found theoracle.oats.jagent.applications.qos jarr file now, so I feel like I am getting closer. I also set up log4j (hopefully correct using this guideline: http://snippets.dzone.com/posts/show/3248).
    However, the execution fails with this error message:
    *[2011-02-09 14:43:45,960]ERROR 0[Thread-2] - oracle.oats.jagent.applications.qos.JavaAgentWrapper.run(JavaAgentWrapper.java:82) - runScript.bat can't be found at null\runScript.bat*
    There are errors when running the script.
    My code looks like this:
    package guiDriver;
    import oracle.oats.jagent.applications.qos.JavaAgentWrapper;
    import oracle.oats.jagent.applications.qos.RunParameters;
    import oracle.oats.jagent.applications.qos.ScriptResult;
    public class OpenScriptWrapper {
         private String m_jwgFile;
         private JavaAgentWrapper m_qos;
         private ScriptResult m_result;
         private RunParameters m_param;
         private static final String RESULT_FOLDER = "C:\\OracleATS\\OFT\\DatabaseChangeTest\\results";
         // the JavaAgent playback process is supposed to finish
         // within this duration specified by users.
         private static final long JAGENT_TIMEOUT = 90000L;
         public OpenScriptWrapper() {
              m_qos = new JavaAgentWrapper();
              m_jwgFile = getJWGFile();
              m_param = new RunParameters();
              m_param.setScriptJWGFile(m_jwgFile);
              m_param.setResultFolder(RESULT_FOLDER);
         private String getJWGFile() {
              return "C:\\OracleATS\\OFT\\DatabaseChangeTest\\DatabaseChangeTest.jwg";
         public void runJAWrapperWithTimeout() {
              m_result = m_qos.run(m_param, JAGENT_TIMEOUT);
              if (m_result == null) {
                   System.out.println("There are errors when running the script.");
                   return;
              System.out.println("Overall Result: " + m_result.getOverallResult());
              System.out.println("Overall Duration: " + m_result.getOverallDuration()
                        + "ms");
              System.out
                        .println("Result Report File: " + m_result.getCsvReportFile());
         public static void main(String[] args) {
              OpenScriptWrapper jaws = new OpenScriptWrapper();
              jaws.runJAWrapperWithTimeout();
    Tips anyone?

  • How to run report from java code

    I am a begginner in Oracle Reports. We have no AS installed, so we run reports either from Reports Builder or by calling rwrun. I would like to know how to embed report calling into java code , let's say into simple swing application. Some example code would be welcomed. Thanks.

    Hello,
    You can find examples in :
    http://download-uk.oracle.com/docs/cd/B14099_17/bi.1012/b14048/pbr_webservice.htm
    Oracle® Application Server Reports Services Publishing Reports to the Web
    10g Release 2 (10.1.2)
    B14048-02
    14 Using the Oracle Reports Web Service
    Regards

Maybe you are looking for