Execute .bat file using cfexecute tag...

Hello,
I am trying to execute a batch file using cfexecute tag. This
batch file needs 1 command line arguement, which I am passing using
arguments
Text attribute.
When I run my batch file directly from command prompt, it
works perfectly. but while using cfexecute, it doesn't seem to do
anything.
Note:- I am trying to encrypt a txt file using GPG algorithm
in the batch file.
Thanks in advance!
Manju

Hello,
you have probally worked this out but if any of this helps :)
I run an application that needs to print via dos command, so
my cfm page makes a batch file writes some arguments to it then
calls it with a cmd. the code is below if any of it helps im glad.
(creates name for my bat file)
<cfset BFname = '#namevariable#' & '.bat'>
(sets up the text I need in the bat file)
<cfset content = 'copy
"c:\inetpub\wwwroot\mct\picklist.txt"
\\MyPrintServer\ThePrinter'>
(writes the bat file with the text in the content var)
<cffile action="write"
file="c:\inetpub\wwwroot\mct\#BFname#" output="#content#">
(calls cmd to run the bat file)
<cfexecute name="c:\windows\system32\cmd.exe"
arguments="/c c:\inetpub\wwwroot\mct\#BFname#"
outputfile="c:\inetpub\wwwroot\mct\log_output.txt"
timeout="1"></cfexecute>
Regards Guy

Similar Messages

  • Execute bat file with cfexecute

    Hello,
    this is a newbie question but I'm stuck. I have a .bat that
    runs fine through the command prompt but won't run with
    <cfexecute>, it merely seems to read the .bat but not execute
    it. The .bat reads:
    java -classpath
    ".;C:\CFusionMX7\wwwroot\i-recall\javaClasses\GATE-3.1\bin\gate.jar"
    AnnieAPI
    When I run <cfexecute
    name="C:\CFusionMX7\wwwroot\i-recall\javaClasses\GateClasspathRun.bat"
    variable="myVar" timeout="100">
    </cfexecute>
    The output looks like this:
    C:\CFusionMX7\runtime\bin>java -classpath
    "C:\CFusionMX7\wwwroot\i-recall\javaClasses\GATE-3.1\bin\gate.jar"
    AnnieAPI
    It simply reads it and doesn't execute the java AnnieAPI
    command. I didn't write this .bat file so maybe I need to add
    something to make it run. Any help is appreciated.
    -Kalen G

    Same thing, just without the classpath in the output:
    C:\CFusionMX7\runtime\bin>java AnnieAPI
    Even if I remove the class path and simply leave java
    AnnieAPI it doesn't run. It should get an error message without the
    classpath or something but I don't And the page loads so quickly
    it's obvious that Coldfusion is just reading the code and not
    executing it.
    Thanks

  • How to execute Bat Files using Jobs?

    Hello, can anyone help me?
    I have created a job like this, but it's not working:
    begin
    dbms_scheduler.create_job(
    job_name => 'job_test'
    ,job_type => 'EXECUTABLE'
    ,job_action => 'C:/temp/test.bat'
    ,start_date => '01/DEC/2006 08:30 AM'
    ,repeat_interval => 'FREQ=DAILY'
    ,enabled => TRUE
    ,comments => 'Demo for job schedule.');
    end;
    begin
    DBMS_SCHEDULER.run_job (job_name => 'job_test',use_current_session => false);
    end;
    Thx!

    Hi,
    This will not work because a batch file is not directly executable. It is executed using cmd.exe .
    So what you need to do is to set c:\windows\...\cmd.exe as the job_action and then as your arguments set
    /q
    /c
    c:\test.bat
    then enable the job. This should work.
    Also make sure the job scheduler service is setup and started (it needs to be started for external jobs to run).
    There is an example given by scotttig in this thread
    Re: dbms_scheduler
    Hope this helps,
    Ravi.

  • Is it possible to execute .bat file located in package ?

    Hi,
    in my application i execute a print.bat file using Runtime.exec(), i'd like to place this .bat in package, let's say com.me.testpackage. How is it possible to execute the batch file from that location?
    thanks

    jschell wrote:
    sabre150 wrote:
    jschell wrote:
    >Simple 'for' loops seem to work OK but still more research needed.
    There is escaping in the for loops which is necessary in a bat file and not needed at the command line.
    It seem to be that any command spanning more than one line fails. Fail? The example that gave shouldn't fail. It should simply run both echos.As I understand it, the command sequence
    @echo off
    goto XXX
    echo out
    :XXX
    echo last
    should just output 'last' and not 'out so if it prints both 'out' and 'last' then in my view it 'fails'. Am I missing something?
    >
    >>
    Makes me even more pleased that I work mainly with Linux.Looking up syntax - what about getopts (bourne and korn)? You can also create 'functions', which can be defined later (if I recall correctly) in the script and called multiple times. I don't know how that would work streaming it in.I don't know about consequences of the streaming approach forward definitions in 'bourne' and 'korn' though I was not aware that 'bourne' allowed them. For 'bash' where forward definitions do not seem to be allowed (could I be mistaken in this?) then using        Process process = Runtime.getRuntime().exec("bash", null, new File(System.getProperty("user.home")));the following very simple 'bash' script (which contains loops, if statements and functions but no goto or forward definitions) can be executed without problems - # Simple bash script
    function sayHello {
        echo "Hello" $1
    sayHello "World" ;
    for i in $( ls /tmp ); do
        echo file - $i
    done
    for i in `seq 1 10`;
    do
        echo "seq" $i
    done
    i=0
    while [  $i -lt 6 ]; do
    if [ $i -eq 4 ]; then
        echo "then" $i
    else
        echo "else" $i
    fi
        let i=i+1
    done
    i=12
    until [  $i -lt 10 ]; do
    echo "until" $i
    let i-=1
    doneIn the past, I have also published examples of how to run Perl scripts using the same basic approach. The heart of the examples is         final String perlScript = "#!/bin/perl\n" +
                "print \"PID $$\\n\";\n" +
                "print \"UID $<\\n\";\n" +
                "print \"EUID $>\\n\";\n" +
                "print \"GID $(\\n\";\n" +
                "print \"\\nProcessing the command line arguments\\n\";\n" +
                "foreach (@ARGV) {\n" +
                "    $n = factorial($_);\n" +
                "    print \"    $_! = $n\\n\";\n" +
                "}\n" +
                "print \"\\n\".'@INC'.\"\\n\";\n" +
                "foreach (@INC) {\n" +
                "    print \"    $_\\n\";\n" +
                "}\n" +
                "print \"\\n\".'%ENV'.\"\\n\";\n" +
                "foreach (keys %ENV) {\n" +
                "    print \"    $_==$ENV{$_}\\n\";\n" +
                "}\n" +
                "$x = theAnswerToTheUltimateQuestion();\n" +
                "print \"\\nThe answer to the ultimate question is ... '$x'\\n\";\n" +
                "sub theAnswerToTheUltimateQuestion()\n" +
                "{\n" +
                "    return 3*2*7;\n" +
                "}\n" +
                "sub factorial()\n" +
                "{\n" +
                "    my ($n) = @_;\n" +
                "    return ($n > 1) ? $n * factorial($n-1) : 1;\n" +
                "}\n";
            System.out.println(perlScript);
             * The perl source can be from any InputStream. Here I use a
             * ByteArrayInputStream just as a demonstration.
            final InputStream perlSource = new ByteArrayInputStream(perlScript.getBytes());
             * The '-' indicates that the Perl script comes from stdin. The "a","b","c" etc
             * are the command line arguments passed to the Perl script.
            final String[] command =
                "perl", "-", "5", "6", "7", "8", "9", "10"
            final Process process = Runtime.getRuntime().exec(command);piping the 'perlSource' stream to the process stdin.
    This runs as expected on both Linux (FC9 and Ubuntu 8.04) and on Windows using Active Perl.
    Please don't take my use of a String to hold the Perl script to mean that I in any way endorse this approach - I just wanted a simple means to create a self-contained example.
    >
    And the c shell has a goto also.One day I might find some time and investigate 'c' shell goto in this context - since I have not used csh for at least 8 years I am very rusty.
    I can't say that the 'streaming' approach will work with all Linux shells but I can say that on Linux I have had no problem with Perl and Bash. If anyone needs to use the 'streaming' approach with another shell then it takes just a few minutes to setup a test harness. If any problems are found then people can always resort to the 'Plan B' approach.
    I am still pleased I work mainly with Linux and Unix.

  • How to execute .sql file using ODI

    Hi All,
    I need to execute .sql file using ODI.
    I tried @{path}{file} command in ODI procedure selecting oracle technology.but it is failing.
    Do any one have any other idea to execute .sql file.
    Thanks in advance

    Ohk...I think you can try creating batch file(.bat) if its Windows & call that from ODIOSCommand.
    The bat file should contain scripts which call .sql file using sqlplus  & there you can use @{path}{file} format.
    See if this helps.
    Regards,
    Santy

  • Can i load a class in subdirectoy  inside a jar file using applet tag?

    hi every one.. thank you for reading ... i am really in dire need for the solution..
    my problem is that i have a jar file contianing a package which inturn contains my applet class...
    i am trying to access this applet class using a applet tag in html file. this html file is in same directory as the jar file. i am having no problems in windows but when i am doing this in linux apache server i was getting class not found exception. (already checked the file permissions). and when i am successful when using simple package directory instead of jar file . so gist of my quesition is "can i load a class in subdirectoy inside a jar file using applet tag in a html file"?

    When you tested in Windows were you using Internet Explorer? On Linux you will be using a different browser, usually Mozilla of some version, or Firefox. Note that the HTML tags for applets will be different between the browsers if you are using the object tag. Principally the classid value for the object tag will differ between Firefox and Internet Explorer.

  • Executing *.bat file from PL/SQL

    Is there anyway for Executing *.bat file from PL/SQL ?
    Thanks

    Try here:
    asktom.oracle.com/pls/ask/f?p=4950:8:15427268967155079552::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:952229840241

  • Executing bat file without using Runtime.exec()??

    Hi all
    From my java App ,I am running a bat file. This is what I did:
    When I press 'execute' button inside my App, it runs a bat file through Runtime.exec() method. Since exec() runs it through cmd.exe, get a DOS window when I press Execute button. If I manually runs my app from command promt , I dont get it. But I have to create a short cut of my main class in the desktop. This is happening when I run my app from desktop icon.
    Now I want to eleminate DOS popup everytime I press execute button. Would anyone pls give an idea how to run bat file without using Runtime.exec()? Any suggestion will be helpful.
    Thanks

    jscell
    Thanks for taking time to answer to my problem .
    Here is what my problem: I create a shortcut of my main class in the desktop. Through this shortcut ,I run my java App. My App has a execute button, When I press this button , It run another bat file through Runtime.exec() method, and show some result in the result PAnel. NOw what happen , I get a DOS command window , everytime I press execute button. , Which is very annoying . But If I run my App thorugh command promt by executing: "java myApp", then I dont get this DOS popup. But I have to create a shortcut in the desktop, so other can use it conveniently.
    NOw I am not sure why I am getting this DOS window in the middle of my Application. IS it for using Runtime.exec() method? or for running bat file through my application? Can anyone pls tell me? I am kind of new to java, and I am learning lot of stuff from this forum .
    Would u pls suggest me about how to eleminate this DOS popup when I press execute button.
    Regrds

  • How to execute .bat file within pl/sql block

    Hi,
    I want to execute a batch file (.bat) file withing a pl/sql procedure. Please guide me for it.
    Regards

    There are several possible ways to make a call-out from a PL/SQL program to the OS on the database server (but not to the client computer).
    You could use java or an external procedure (you'll need to code it in C) for example.
    You might be able to make use of UTL_HTTP to talk HTTP to another server or UTL_TCP to talk TCP to another server.
    What is it you are trying to do?

  • Executing bat files from another location

    Hi
    In my application i need to execute a bat file which is in another location.
    i have my class file in c:\ds and i want to execute the bat file in c:\ds\src\jython.
    This is the code i have used
    private void executeBootstrapBat(){
    String cmd=null;
    cmd="cmd /c bootstrap C:\\DS\\HelperApplication\\src\\conf\\wsadmin-local.properties" +
    " " + getXmlFileName() + " " + getVOB();
    Runtime rt = Runtime.getRuntime();
    try{
    Process pt = rt.exec(cmd);
    }catch(IOException e){
    e.printStackTrace();
    }

    You can execute the bat file in any location. Butyou
    have to set the classpath in that location whereyou
    are executing the bat file.Please stop giving advice on this site. You do not
    have any clue what you are talking about at all.Actually I just went looked at a few more of your posts. All complete rubbish. Again please stop posting replies on this site until you get some clue about anything. It is very wrong of you to post replies like you know what you are doing and misleading those who don't know any better.

  • Problem in executing bat files

    hi all
    I developed one console application which has two components;one utility componet and a main componet and both are developed as maven project.i successfully build the componets by successfully set the dependencies.
    i got two jar components.
    then i did the following things
    1.Create one folder ,Say Application
    2.create lib,resources,log folders under Application
    * resources is for logconfiguration file and propertiesfile
    * log folder is for log fles
    * lib is the folder where i place my two jar files
    3.create a .bat file by editing a text file with the following contents and give a .bat extension
    java -cp
    /lib/mainModule.jar;/lib/utilityModule.jar com.my.package.Starter
    Problem:-i got the following message while i was trying to execute the bat file
    "Failed to load Main-Class manifest attribute from /lib/mainModule.jar"
    Do i need to do more configuration on that.....please help
    mobi

    so you use bat, why you use -cp option?
    you can write it as:
    set classpath=%classpath%;/lib/mainModule.jar;/lib/utilityModule.jar
    java com.my.package.Starter

  • Execute bat-files

    Hallo,
    I have a problem with the new method execute.
    We have used gui_exec to run a bat-file with
    > command   = c:\file.bat
    > parameter = "c:\my file.txt"
    Now we do the same with the execute.
    > application = c:\file.bat
    > parameter   = "c:\my file.txt"
    but this does not work.
    It works without the quotes, when the path
    has no blanks in it. But it's the user
    how chose the path ...
    Regards,
    Christine

    Hello Joerg,
    thanks for the debugging code for the batch.
    I have done a lot of tests with NT and XP:
          para = l_parameter.
          com  = l_application.
    *CALL FUNCTION 'GUI_EXEC'
    EXPORTING
       COMMAND          = com
       PARAMETER        = para.
    or
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
      EXPORTING
        APPLICATION            = l_application
        PARAMETER              = l_parameter.
    Testing with NT
    With the GUI_EXEC I get the file dump.txt with:
    Command line: { "D:\test mit leer\mit_.txt"}
    Command line arg #1: {"D:\test mit leer\mit_.txt"}
    The same with EXECUTE: there is no dump.txt-file.
    Testing with XP:
    both the GUI_EXEC and the EXECUTE are writing
    the dump.txt-file with the same content as above.
    So the problem is only with NT and there are
    only a few with it left. They have to use path
    without blank or use XP ...!
    Thanks for your help.
    Regards,
    Christine

  • Variable not set (error 91)/Error during import (error 102)/execut bat file

    We are on BO 11.5.0.0 and using the COM SDK with Visual Basic to run multiple reports (sometimes multiple flavors of the same report) through a bat file.
    If we run the reports single-threaded through the bat file, the reports run fine.  However, if multiple versions of the bat file start at approximately the same time, we get one of two errors:
    91 Object variable or With block variable not set
    102 Error during import document -
    Here's the part of the code with the problem:
    Dim BOapp As busobj.Application
    Dim receiveDoc As busobj.Document
    Set BOapp = New busobj.Application
    BOapp.Interactive = False
    BOapp.Logon strUser, strPass, strFromSystem, "Enterprise", False, False
    BOapp.Visible = False
    Set receiveDoc = BOapp.Documents.OpenFromEnterprise(strFromRep, strFromFolder, boFolder)
    receiveDoc.SaveAs (strDocumentPath & strFromRep & ".REP")
    Values for the following variables are passed in from the bat file:
    strUser
    strPass
    strFromSystem
    strFromRep
    strFromFolder
    strDocumentPath
    If it fails on the OpenFromEnterprise statement, we get the 102 error.
    If it fails on the SaveAs statement, we get the 91 error.
    Running it through debug hasn't helped, since we are running only one report.
    Any thoughts on what could be going wrong?
    Thanks in advance

    I have tried this running the VB code on my desktop (outside of the bat file) and nothing out of the ordinary occurs.  The VB code runs fine with only one occurrence.
    I had seen on other posts "ThisDocument" and didn't know if it would be applicable in this situation.  I also wasn't sure how it should be used based on the rest of my code.  Would "ThisDocument" make a difference?
    Thanks again

  • Need to execute bat file by GPO with admin rights

    Hi all
    I created a specific bat file that run regini.exe with specific parameters to set a specific permission in a specific registry key.
    I can execute this bat file from GPO but I need that this bat runs with domain admins rights otherwise script not set the permission in user's registry key.
    Have you any ideas?
    Thanks
    Chris

    > Yes I tested this solution but it's not possible set permission to the
    > key :-(
    Which key are we talking about?
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • Error : How to execute *.BAT file

    Some of the friend said me to execute any file following code
    Runtime rt=Runtime.getRuntime();
    Process pr=null;
    pr = rt.exec("cmd.exe /c start " + "myfilename");
    I get error as
    CreateProcess: cmd.exe /c start myfilename error=0
    Press any key to continue . . .
    what is cmd.exe /c start in exec().
    Thanks..

    hi Bhavin
    try this code because i had the same problem an d this thing works for me here is the code
        // Get file name
        String File_Name = // What ever yr file name get as String
        // Get Operating System Name
        String os_name = System.getProperty("os.name");
        os_name = os_name.toUpperCase();
        // Declare command as array of string
        String[] command ;
        // on Windows XP, NT, 2000 command is different and on win 98, 95 is different
        if(os_name.indexOf("XP") != -1){
             command = new String[] {"cmd", "/C", "start", "\"\"", File_Name};
        else if(os_name.indexOf("NT") != -1){
             command =new String[] {"cmd", "/C", "start", "\"\"", File_Name};
        else if(os_name.indexOf("2000") != -1){
             command = new String[] {"cmd", "/C", "start", "\"\"", File_Name};
        else  {
             command = new String[] {"start", "\"\"", File_Name};
        try
            // Run the commands using Runtime
            Process process = Runtime.getRuntime().exec(command);
        catch(IOException ioe)
            //show Error message
                  JOptionPane.showMessageDialog((Component) null,
                                          "Unable to Locate the file..."+
                                          "\n"+ioe.getMessage(),
                                          "Error...",
                                          JOptionPane.ERROR_MESSAGE);
        }Regards
    Satinderjit

Maybe you are looking for