Running script file from VB

Hi,
Is there any shell command or exe to run oracle script file from VB?
thanx

You should be able to call WinExec() (Windows API) there are bound to be MS KB articles that cover this. Create a small CMD file that you pass a parameter to with the SQL Script name and then exec that.

Similar Messages

  • Running @Script.sql from inside C#

    I'm trying to include a script file as part of a deployment. I'm able to connect to my Oracle XE database in code and run stored procedures as well as text commands. My deployment will copy a script file into an install directory for later use. When the user activates history recording, I want to run this script file.
    I can run the script manually...@"C:\Program Files\History Setup\TestScript.sql"...without issue. Works just fine.
    Currently I recieve an invalid sql command error. At the moment I'm trying:
    Command.Connection = myconnection;
    Command.CommandText = @"@""C:\Program Files\History Setup\TestScript.sql""";
    Command.CommandType = CommandType.Text;
    try
    Connection.Open();
    Command.ExecuteNonQuerry;
    catch (Exception ex)
    error handling
    If anyone has advice for running script files from inside C#, it would be appreciated.

    The other Dennis is correct. You must cleanup the text.
    This should give you a start. I have had good results using the forward slash as a delimiter.
    r,
    dennis
    byte[] ba = GetFileContent("SomeFileName");
    string All_My_Statements = Encoding.UTF8.GetString(ba);
    ExecutScript(NetConnectionString, All_My_Statements);
            public void ExecuteScript(string _connectstring, string _final_statements)
                   string[] cmd_seq = _final_statements.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < cmd_seq.Length; i++)
                    string act_cmd = cmd_seq;
    string tmp = actcmd.Replace("\r\n", "");
    act_cmd = _tmp;
    if (act_cmd.Length > 2)
    try
    int r = ExecuteTextNonQuery(_connectstring, act_cmd);
    if (r == 1) // success
    LogThis("\tSuccess:" + act_cmd);
    else
    LogThis("\tExecuted:" + act_cmd);
    catch (OracleException) { LogThis("\tException:" + act_cmd); }
    catch (System.Exception) { LogThis("\tException:" + act_cmd); }
    public static byte[] GetFileContent(string f)
    byte[] ba = null;
    try
    System.IO.FileStream fs = new FileStream(f, FileMode.Open);
    System.IO.BinaryReader br = new BinaryReader(fs);
    ba = br.ReadBytes((int)fs.Length);
    br.Close();
    fs.Close();
    catch (System.Exception) { };
    return ba;
    public static int ExecuteTextNonQuery(string connectionString, string exec)
    int rtn_int = -1;
    using (OracleConnection oraconn = new OracleConnection(connectionString))
    string execcmd = exec;
    try
    _oraconn.Open();
    using (OracleCommand cmd = new OracleCommand(_execcmd, _oraconn))
    cmd.CommandType = CommandType.Text;
    rtn_int = cmd.ExecuteNonQuery();
    catch (OracleException _oraEx)
    throw (_oraEx); // Actually rethrow
    catch (System.Exception _sysEx)
    throw (_sysEx); // Actually rethrow
    finally
    if (_oraconn.State == ConnectionState.Broken || _oraconn.State == ConnectionState.Open)
    _oraconn.Close();
    } //using _conn
    return rtn_int;

  • Thanks for your help. But couldn't run script files

    Hi Saar:
    Thanks for your advise on creating shared folders on VM ware Red hat Oracle to run script files stored on my local F: drive.
    However I got this error when I tried to load and run a script file "Bookscript.sql" in i*sqlplus:
    SP2-0869: invalid file content.
    Path to file is :
    /mnt/hgfs/OracleVM_1/OracleVM_1/9iSQL/JustLeeDatabase/Bookscript.sql.
    Why is this so what can I do to run it?.
    I*SQLPLUS error messages recommends to make sure the browser has "SQL" MIME type.
    Action: Make sure that the script is in a text file and the MIME type settings needed by the browser to recognize the file are set correctly. Typically if you are loading a file with the extension .SQL, make sure the browser has a "SQL" MIME type.
    How do I do that?
    Thanks

    I assume that you are trying with the browser inside the VM, mozilla 1.4 I think. Please try with IE 6 or Netscape 7.2 from the Windows host access the same exact URL it will talk to the linux box, I trust the script will load and this is an issue with how mozilla 1.4 loads files, it might be fixed in later versions of mozilla. If problem still exists, copy the file to /tmp on the linux box and repeat test.
    let us know. In the future please reuse your existing thread until the issue is resolved.
    good luck,
    Saar.

  • How can I rip a 10" x 10" post script file from InDesign 6, it keeps telling me "the active document

    How can I rip a 10" x 10" post script file from InDesign 6, it keeps telling me "the active document uses multiple pages sizes and won't print.  My page sizes are all 10" x 10"

    Please post in the InDesign forums here http://forums.adobe.com/community/indesign/indesign_general. They will be able to help you.

  • Running class files from the windows command line...

    Hello Everyone,
    My instructor showed us a way to run class files from the windows command line. However every time I try to run the class file from the command line using a command like: java CruiseHelper.class
    I get an error that states "Exception in thread "main" java.lang.NoClassDefFoundError: CruiseHelper/class"

    Hello Everyone,
    My instructor showed us a way to run class files from
    the windows command line. However every time I try
    to run the class file from the command line using a
    command like: java CruiseHelper.class
    I get an error that states "Exception in thread
    "main" java.lang.NoClassDefFoundError:
    CruiseHelper/class"Classes are not file names. You don't have a class named "CruiseHelper.class", that's a file name. The class name is just CruiseHelper (if you have no package statement in it).
    So,
    java -classpath . CruiseHelper

  • Error running batch files from java source file???

    Dear Friends,
    hi,
    this is with response to a doubt i had earlier ,
    i want to run batch files from the java source file ,i tried using this code (here batrun is the batch file name that contains commands to run other java files)
    try
    String [] command = {"c:\\vishal\\finalmain\\batrun"};
    Runtime.getRuntime().exec(command);
    catch(Exception e)
    but i got the following error.
    java.io.IOException: CreateProcess: gnagarrun error= 2
    plz. help me, i tried all combination w/o success,
    in anticipation(if possible give the code after testing)
    Vishal.

    hello there,
    i solved the prob. by using
    cmd /c start filename ,but i need to pass parameters ie
    cmd /c start java "c:/vishal/runfile a b" where a and b are the parameters. but it is not accepting this in Runtime.getRuntime.exec(),
    any solutions ?????????
    regards,
    Vishal

  • Running  .nsi file from java

    hi,
    Ho to run .nsi file from java.
    thanks in advance.

    User845466 wrote:
    Ho to run .nsi file from java.Find the program hanling that kind of documents an launch this via Runtime.exec() giving it your *.nsi file as a parameter.
    bye
    TPD

  • How to run script file ( unix script file like ksh or sh file) using Java

    How to run script file ( unix script file like ksh or sh file) using Java Program?.
    I am using the following code snippet to run the simple commands like top or ls ,etc....
    Runtime runtime = Runtime.getRuntime();
    Process proc = runtime.exec("top");
    Thanks In Adavance
    -Siva

    String [] { "ksh" , "-c" , "script", "arg 1", "arg 2", "arg 3"}

  • How to run batch file from oracle forms 9i

    Hi everyone.
    i have a data in csv file. i want to upload it to my database. i am using sql loader for it.
    i have made a batch file which run the sql loader and transfer my data to database.
    How to run batch file from oracle forms 9i.
    when i press the button, nothing uploads in my database. (when i simply run the batch file it works).
    here is my code
    Begin
    HOST('C:\temp\batchfile.bat');
    message('done');
    end;
    Thanks in advance
    regards
    sajid

    this is my log file, when i run manually.
    SQL*Loader: Release 10.2.0.1.0 - Production on Thu Jul 1 23:27:53 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Control File: file_to_upload.ctl
    There are 2 data files:
    Data File: sk.csv
    Bad File: sk.bad
    Discard File: none specified
    (Allow all discards)
    Data File: sk1.csv
    Bad File: sk1.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    Table KHAN, loaded from every logical record.
    Insert option in effect for this table: APPEND
    Column Name Position Len Term Encl Datatype
    SR FIRST * , O(") CHARACTER
    DATES NEXT * , O(") CHARACTER
    AGENT NEXT * , O(") CHARACTER
    COUNTRY NEXT * , O(") CHARACTER
    TRANSACTIONS NEXT * , O(") CHARACTER
    PKR NEXT * , O(") CHARACTER
    USD NEXT * , O(") CHARACTER
    BANK NEXT * , O(") CHARACTER
    Table KHAN:
    11088 Rows successfully loaded.
    0 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Space allocated for bind array: 132096 bytes(64 rows)
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 11088
    Total logical records rejected: 0
    Total logical records discarded: 0
    Run began on Thu Jul 01 23:27:53 2010
    Run ended on Thu Jul 01 23:27:54 2010
    Elapsed time was: 00:00:00.63
    CPU time was: 00:00:00.17

  • APEX: How to execute Script file from APEX

    Hello All,
    Can anyone tell me how to execute script file from APEX?(Step by Step process)
    Thanks & Regards,
    Jiten Pansara

    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21677/sql_rep.htm#AEUTL193
    Regards,

  • Calling a sql script file from a function.

    Hi,
    I need to call a sql script file from a user defined function. Currently i am trying to do this in Oracle SQL Developer. i tried calling with
    @ {filename}, EXECUTE IMMEDIATE etc, but nothing worked. I get the Compiler error.
    Basically my need is to call catldap.sql file so that DBMS_LDAP package gets loaded and then I can call the API functions from this.
    Please let me know if this is possible doing in a PL/SQL function.
    thanks,
    Naresh

    user784520 wrote:
    I need to call a sql script file from a user defined function. Not possible.. and it seems that you do not fully understand the client-server within the Oracle context.
    All SQL and PL/SQL are parsed and executed by an Oracle server process. The SQL and PL/SQL engines each expects a single command block at a time. Neither of these can accept a series of separate commands as a single call and then execute each in turn. The SQL engine expects a single SQL statement at a time. The PL engine expects a single PL/SQL anonymous block at a time.
    This server process also cannot break into the local file system to access script files. Nor can it hack across the network to access script files on the client.
    In order for the server process to access local files, a directory object needs to be created and the current Oracle schema needs read and/or write access on that directory object. As sound security principles apply.
    There's no PL/SQL command to execute a script. You must not mistake SQL*Plus commands (this client has a very limited vocabulary) with PL/SQL commands. SQL*Plus executes its own commands.. and send SQL and PL/SQL commands (a statement block a time) to the Oracle server process to be serviced and executed.
    It is also a very bad idea to execute external script contents from inside an Oracle server process - as that script resides externally and thus outside Oracle's security mechanisms. This means that is is pretty easy for someone to access that script, compromise it, and then have you inject and execute the contents of that script into the database.
    It is not sound security.
    Last issue - it is even worse to have application PL/SQL code dynamically creating (or trying to create) portions of the Oracle data dictionary and PL/SQL call interface.
    The database needs to be installed correctly - and this includes loading and executing the required rdbms/admin scripts during database installation. It does not make sense at all for application code to try and execute such scripts. It raises numerous issues, including having to allow that application code full and unrestricted SYS access to the database instance. A very serious security violation.
    I do not agree at all with the approach you want to use.

  • Running exe files from java applications

    Hello All,
    Is it possible to run executable files from java applications?
    I need to run an exe file on the client from the server machine, the exe could reside on either the server or any other machine on the LAN. Is it possible to specify the path of where the exe resides, and run it on a client machine?

    HI,
    I tried to launch a MS Word application using runtime.exec but it gives me some problem
    The foll. code to launch a txt file using notepad works.
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"notepad.exe","C:\\coo7\\wizard.txt"};
    Process child = rt.exec(callAndArgs);
    However, oif I try to launch a MS Word application, it asks for the entire path of WINWORD.exe, (unlike just specifying notepad.exe as the first argument in String[] callAndArgs) and this can vary from one machine to another.. how do I get around this?
    The foll. code snippet works but the complete path of where WINWORD.exe might be installed on any machine, is not fixed:-(
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"C:\\Program Files\\Office\\Office10\\WINWORD.exe","C:\\coo7\\wizard.doc"};
    Process child = rt.exec(callAndArgs);
    Any idea/suggestions pls..

  • How to run .cmd file from a Powershell script

    Hi,
    I would like to know how I run commands from a powershell script? how to use the invoke-command?
    This powershell script doesnt work for me
    Invoke-Command C:\setup.cmd -ArgumentList install-setupforced

    To run a batch file from powershell, just type its name with arguments. I'd recommend explicitly including the .CMD file type and, if it is located in the current folder, powershell rules require you to explicitly say so, i.e.:
       ./mybatch.cmd inputfile.txt outputfile.txt
    To run a single cmd.exe command, just prefix it with cmd.exe /c as Mike says:
        cmd.exe /c color 48
    to run a series of "&"- separated cmd.exe commands you need to enclose the complete command string in double quotes:
        cmd.exe /c "color 37 & dir"
    Beyond that it can get complicated due to various characters that are special to powershell and those special to cmd.exe. If you need to run a series of cmd.exe commands, your best short term bet is to put them in a batch file. The best long-term bet is
    to move more completely to the powershell way of doing things...
    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

  • Issues while running batch file from SAP

    Dear Experts,
    I am executing a script from SAP which is running fine on my PC. But when I execute the same on user's PC he is getting the following error:
    1. "Open File - Security Warning" pop-up appears when I execute the code on user's PC. The same does not appear on mine. I click on "Run" then it executes.
    2. After the script gets run, SAP is not moving to another screen and gets hanged. It displays a message below "Running Script.bat' (and waiting)'...". Again this issue is only replicated on user's PC.
    Regards,
    Ashish
    Also guys let me know how to insert screen shots in SDN messages.
    Moderator message: not directly related to ABAP development.
    Edited by: Thomas Zloch on Apr 25, 2011 10:41 PM

    Not an ABAP issue...contact your Helpdesk.

  • Running batch files  from Java using exec method

    Hi,
    I want to run a batch file from my Java program like this:
    try {
    Process proc = Runtime.getRuntime().exec("C:\\Refresh.bat");
    catch (Exception e) {
    MessageBox.show(e.getMessage());
    Refresh.bat file contains two commands.
    First one unzips certain zip file.
    Second one refreshes a SQL Server database using osql utility.
    Problem is that when program is run it executes only the first command and hangs on the second one.
    Please help.
    TIA
    Ravinder

    From the FAQ:
    2. How do you launch an external program on a Microsoft Windows platform from a program developed on the Java [tm] programming language?
    The following will launch notepad in Microsoft Windows NT:
    Runtime.getRuntime().exec("cmd /c notepad.exe");
    To launch a program in Microsoft Windows 95/98 use:
    Runtime.getRuntime().exec("c:\\windows\\notepad.exe");
    The Runtime class allows interaction between a program and its environment. The first string command instructs the command line interpretor, cmd to open up the calculator application.
    The exec() methods do not use a shell; any arguments must have the full pathname to the shell as well as the command itself.
    For example, to run a shell on the UNIX� platform, type:
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("/usr/bin/sh -c date");
    To run a batch file under Microsoft Windows 95/98:
    Process p = rt.exec("command.com /c c:\\mydir\\myfile.bat");
    To run a batch file under Microsoft Windows NT:
    Process p = rt.exec("cmd /c c:\\mydir\\myfile.bat");
    where 'cmd' and 'command.com' are the command-line interpreters for Microsoft Windows machines.
    The Runtime.exec() methods might not work effectively for some processes on certain platforms. Special care should be taken with native windowing, daemon, WIN16/DOS process or some shell scripts.
    regards,
    jarshe

Maybe you are looking for