Successfull .Bat file execution

Hi,
I have a .bat file consisting couple of actions /tasks ...
Rem Task 1: Using ImageX to deploy a image stored on USB .
                    Imagex /apply /U:\install.wim /index:3 D:\
Rem Task2 : Copy a folder from USB to D drive
                    xCopy U:\Temp D:\Temp2
Now I want to add some logic into the bat file, for example if a task is interrupted (maybe be source disk is not available or removed, like USB or network resources etc) or there is no folder with name Temp (for example), can  I get a VB message box
with saying something went wrong, start again _???
N.A.Malik

If you write your batch file in a modular fashion then you can check for any criteria as shown below. You will have to write the individual code segments yourself.
@echo off
set result=OK
call :CheckDiskSpace
if not %result%==OK goto :eof
call :FileSize
if not %result%==OK goto :eof
etc.
goto :eof
==============
:CheckDiskSpace
. . . Your code goes here
if %Free% LSS 100000000 set OK=false
goto :eof
==============
:FileSize
. . . Your code goes here
if %Size% GTR 100000000 set OK=false
goto :eof
==============

Similar Messages

  • Bat File execution Problem in Win Server 2k3

    I have a jar that is calling a .bat file.
    It executes the bat file in Windows XP, and Windows 2000
    But when I run it in Win Server 2k3 it can't execute.
    I get Exit Value 1
    Does anyone know any differences between the Operating Systems that could cause this?
    Thanks
    Paul

    I don't know enough about the difference in system or even between your two installation. An exit 1 error could happen for any reason, such the batch file not being found or other reason.
    The best thing to do is get a handle to the stderr and stdout of the process and display them. To do this you would write a class that reads from an InputStream (the output of the process is read using an InputStream) and displays to System.out. Follows is some code that illustrates this (done off the top of my head, more or less, so it won't necessarily execute as is):
       void runExternalTask()
          String cmd = new String { "myexecutable.exe" };
          Process proc = Runtime.getRuntime().exec(cmd);
          ProcessOutputHandler procOut = new ProcessOutputHandler(proc.getInputStream(),0);
          ProcessOutputHandler procErr= new ProcessOutputHandler(proc.getErrorStream(),0);
       public static class ProcessOutputHandler implements Runnable {
            InputStream _in;
            //PrintStream _out;
            boolean run = true;
             * Constructor for ProcessOutputHandler.
            public ProcessOutputHandler( InputStream in, int procID ) {
                _in = in;
                (new Thread(this,"output.handler."+procID)).start();
            public void close () {
                run = false;
            public void run() {
                try {
                    int i = 0;
                    while ( run && (i=_in.read()) != -1 ) {
                        System.out.print((char)i);
                } catch (IOException e) {
                  e.printStackTrace(System.err);
        }

  • Bat File Trace

    Hi
    I use bat files scheduled to execute batch script late night.
    at the end of the execution i have no clue that now many statements in batch process successful and how many statements fail to execute.
    Is there anyway i can make a log of my bat file execution to see success and fail of all statements after execution?
    Wishes

    Redirecting Output to a File in Windows Batch Scripts
    http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/
    Regards,
    Sabdar Syed.

  • Running Oracle startup or shutdown bat file from Java code

    I have two bat files for the startup and shutdown of Oracle instance which works fine from the command prompt. But my requirement is to run it through a Java program. Please reply with full Java code. Also mention how I would get the status of the bat files that it is successfully executed or not and if not what is the error.

    Your program is working fine, but there is another problem. What's happening now is I have to open the Login screen after the startup of oracle server is complete, but the next line of my program after Runtime.exec is the LoginScreen.show which immediately shows the login screen after executing Runtime.exec and when I am giving the login name and password and press enter, it shows Oracle not available exception, because the startup process is still in progress. I want to stop the execution of my next line of code until and unless my process of Oracle startup is complete.

  • Setting Oracle environment variable using batch (.bat) file in windows

    Hi,
    Oracle 9i db
    Windows OS
    I am in process to create the database (Considered that Oracle9i software is already installed) by running one batch file which consist of all the scripts for the database creation.
    But i also want to set the environment variables at MyComputer(right click)>properties>advance>environment, permenently by running the batch (.bat) file
    ORACLE_HOME
    ORACLE_BASE
    ORACLE_SID
    So, how can it be done ?
    With Regards

    Hi,
    *@echo off*
    set ORACLE_SID=iprsdb
    set ORACLE_BASE=C:\oracle
    set ORACLE_HOME=C:\oracle\ora92     
    call C:\install_bkp\test_env_var.bat
    echo Test Successfull.
    Above mentioned is the code written in the batch (.bat) file
    In that i have also called another .bat file which test the env. variable values which is as below:
    c:\>test_env.bat
    ===================
    Testing oracle sid
    ===================
    iprsdb
    =====================
    Testing oracle base
    ===================
    C:\oracle
    =====================
    Testing oracle home
    =====================
    C:\oracle\ora92
    Test Successfull.
    But when i checked at MyComputer(right click)>properties>advance>environment variables
    there, I saw none of the entries from the above, why so ?
    how to set env. variables permanently using the DOS commands. ?
    With Regards

  • Running .bat files from java code

    Dear Forum,
    I have seen numerous postings on the web about this question, still I have found no answer that works (for me)
    I�m trying to run a simple .bat file from a piece of java code , however it does not work. No error message , but still.
    Does anyone have a tip?
    best regards
    temuj
    try{
                String cmd = "cmd.exe C:\\mybat.bat";
                Runtime.getRuntime().exec(cmd);
    catch(IOException e){System.out.println("ERROR: "+e);}Message was edited by:
    temujin

    "cmd.exe C:\mybat.bat" is being passed to the OS for execution
    what happens when in a terminal/dos window you execute letter for letter:
    cmd.exe C:\mybat.bat
    The output will be identical to what is happening when java makes this call.

  • How to run the cmd or bat files in the con current program R12 Windows

    Hi,
    I would like to run one cmd or batch file, usually it is looking exe file only.
    How do we register the cmd or bat files?
    We encountered lot of problems to call the exe files, now we want to know to use the cmd file or batch or prog file (abc.cmd or abc.bat or abc.prog)
    Application: R12.0.4
    OS: Windows 2003
    Awaiting for your sincere response,
    Thanks,
    M.K.Thamaraiselvan

    Hi Hussien,
    Please help me that
    1. Create a file under the %FND_TOP%\bin directory called testhost.cmd
    In the file put the following two lines:
    ls >> testhost.txt
    exit
    2. From the %FND_TOP%\bin directory, do the following:
    copy fndcpesr.exe testhost.exe
    I understood the above 2 steps, the below one, is making confusion. Can you explain that what application i have to choose. 3. Register testhost (use 'testhost' for the Execution File Name) as a concurrent executable in Oracle Applications.
    4. Register a testhost host program as a concurrent program in Oracle Applications.
    5. Add the program to your report group.
    Awaiting for your explanation clearly to go ahead.
    Please explain me that which application i can choose while define the executable and program.
    awaiting.
    Thanks
    M.K.Thamaraiselvan

  • Dot BAT files in Windows 8.1

    How do you activate the dot Bat file for execution on the workspace and/or in the startup menu?
    Jim

    Hi Jim,
    Could you please explain a bit for the activate here refers to?
    If you mean to run the bat files, we may consider take use of group policy to run it at startup, or use the Scheduled Tasks, for more information, please check the articles below:
    Use Startup, Shutdown, Logon, and Logoff Scripts
    Batch Files – Basic Error Checking and Running as Scheduled Tasks
    If I have any misunderstandings, please feel free to let me know.
    Best regards
    Michael Shao
    TechNet Community Support

  • 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
    ::

  • Create a Package in SCCM 2007 to use a robocopy bat file

    Hi
    I’m setting up a package for Robocopy that copy files from C drive of a target machines into a network share.  
    This is the robocopy bat file i am using:
    ROBOCOPY "C:" "\\servername\Test" /tee /e /eta /copy:dt /r:01 /w:01 /log+:"\\servername\Test\testLog.txt"
    /if *.doc *.xls *.ppt *.pdf *.msg *.pst *.jpg *.zip *.txt
    t
    -I Set up a package with this batch file
    -Added a program to the package pointing to this batch file
     general program properties are:
     Run:Hidden
     After running:No actionrequired
     Environment:
     Run with administrative rights
     drive mode: Runs with UNC Nam
    -Advertised it to a collection
    But when after the advertisment  i get the following error and nothing gets copies:
    Script for Package:CHV02E94, Program: ITF Robocopy failed with exit code 16
    Any advice

    I tried to test the same thing using a local source to get the script to work first and once this is working I will change it back to network share. This way i can eliminate possibilities of having any issues with permission and local system account.
    Here is the batch file:
    ROBOCOPY "C:" "\\machinename\Test" /tee /e /eta /copy:dt /r:01 /w:01 /log+:"\\machinename\Test\testLog.txt" /if *.doc *.xls *.ppt *.pdf *.msg *.pst *.jpg *.zip *.txt
    Using local source is  giving me still some issues. It seems like the robocopy.exe is using a default location as source other than C:\ which I want to. This script should scan the entire local C drive and copy any files that have specific
    file format as above.
    Here is the Execmgr.log error: Execution is complete for program ITF Robocopy Local2. The exit code is 3, the execution status is FailureNonRetry
    The robocopy log shows this:
       ROBOCOPY     ::     Robust File Copy for Windows                             
      Started : Sun May 08 09:19:51 2011
       Source : C:\Windows\System32\CCM\Cache\CHV02EB1.2.System\
         Dest : \\L3C84706457\Test\
        Files : *.doc
         *.xls
         *.ppt
         *.pdf
         *.msg
         *.pst
         *.jpg
         *.zip
         *.txt
      Options : /TEE /S /E /COPY:DT /ETA /R:1 /W:1
                        1 C:\Windows\System32\CCM\Cache\CHV02EB1.2.System\
       *EXTRA File          0 testLog.txt
         New File        8714 New Microsoft Office Excel Worksheet.xls
      0% 
    100% 
                    Total    Copied   Skipped  Mismatch    FAILED    Extras
         Dirs :         1         0         1         0        
    0         0
        Files :         1         1         0         0        
    0         1
        Bytes :     8.5 k     8.5 k         0         0         0        
    0
        Times :   0:00:00   0:00:00                       0:00:00   0:00:00
        Speed :             1742800 Bytes/sec.
        Speed :              99.723 MegaBytes/min.
        Ended : Sun May 08 09:19:51 2011
    why is the source location getting changed to ==>C:\Windows\System32\CCM\Cache\CHV02EB1.2.System\?????

  • Executing commands within .bat file sequentially within the same cmd window

    We have a .bat file that contains several commands. Each command invokes an .exe with arguments.
    When I invoke the .bat file programatically using the command "cmd.exe /c myfile.bat", the commands are running parallelly.
    Within the .bat file, I also tried using start "" /wait /b "myprocess.exe" instead of just
    "myprocess.exe", but both gives the same result.
    Any solution to this?
    Note:
    We use Windows 7 environment.

    I am invoking the batch programatically in c#.
    As per your suggestion, I modified the code as below to execute bat file directly instead of using cmd.exe.
    Process proc = new
    Process();
    proc.StartInfo.FileName
    = "c:\\myfile.bat";
    proc.Start();
    But still I could see the parallel execution of commands within the bat file.
    I was not able to use Call command as I have to invoke programatically.
    Is there a way to invoke Call command from c#?

  • Test Stand seq w/ dll batch file execution not working

    I am using Test Stand 4.1, running a seq that calls a dll.  The dll contains a batch file execution function that has not been working properly.  I am not 100% sure what the function is as I do not have access to the direct code from which the dll was created.  I believe I have a file, however please remember this is a guess that I am looking at the correct function/file. 
    This is a Pass/Fail test step that calls a batch file.  The batch file runs properly without the use of Test Stand and called by the dll.  In the code that I believe is running, I see there is a step that I am guessing does not run (see below for test steps).  It seems as though these steps are being "stepped over" and not running, however the test does seem to be entering this function.  The test reports a pass/fail status as the data is reported into a txt file.  If the txt file contains the correct data, the test step reports PASS, even though the batchfile does not run.
    :Note:  [batchfile.bat] is the name of the batch file being called; the [ ] are not present 
    // Run Batch File
     ChkErr(LaunchExecutableEx([batchfile.bat] ,windowState,&handle));   
     // Wait for batch file to complete task
     do{
      ProcessSystemEvents();
     }while(!ExecutableHasTerminated (handle));
     RetireExecutableHandle (handle);
    Any one have any suggestions as to why the batch file is not being called and running properly?
    Thank you
    Jason_C

    Thanks for the feed back.  I have realized and it seems as though sometimes the CWD varies.  The current working directory when the batch file does not run seems to be set to the desktop, not to the specified directory.  The batch file is used to program a chip, calling the exe to run using commands.  The file are speciifed by an absolute path, however the exe is not.  The batch file is as below and seems to match up with a problem with the CWD.  How can change though?  I will have to check in the Start in field, but where can I find that property? 
     Thank You
    --Jason
    del ..\misc\mplab.txt
    echo C:\Program Files\JTRS\01_P55461U\bin\uutsw\CR1_T2V3L_PMM_STUB_LOAD.hex
    ..\misc\pm3cmd /5 /BLCC:\Program Files\JTRS\01_P55461U\misc\t2v3l_pmm_stub_load\t2v3l_pmm_stub_load.pm3 /k /m /y /e >> ..\misc\mplab.txt >> ..\misc\mplab.txt
    ..\misc\pm3cmd /5 /BVCC:\Program Files\JTRS\01_P55461U\misc\t2v3l_pmm_stub_load\t2v3l_pmm_stub_load.pm3 >> ..\misc\mplab.txt

  • 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 Doug

    LLUSERSPROFILE=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

  • HELP:: Flash unable to open BAT file or PPT file

    HELP Please....
    I am using Flash MX.. my projector exe file doesnt seem to
    open/call
    "myppt.bat" file which calls a powerpoint (PPS) file after
    the animation is
    over. The bat file runs well when
    self executed but not from flash...
    I also installed the trial version of Flash 8 and seem to be
    having the same
    above problem.
    please help by providing a working solution.

    Use FlashJester JStart
    http://jstart.flashjester.com
    p.s Beware, a double posting is not seen too good..
    Regards
    FlashJester Support Team
    e. - [email protected]
    w. -
    http://www.flashjester.com
    There is a very fine line between "hobby" and
    "mental illness."

  • Reading the registry from a .bat file

    I've searched a bit on web before asking and I apologies a head of time but my knowledge of .bat files is a little lacking. Currently I have a working .bat file I created, but was looking to adding something extra to it and just can't seem to find exactly
    what I need.. What i'm looking to do is at the top of .bat file I want it to read the registry here HKEY_LOCAL_MACHINE\SOFTWARE\IS_DEPT\Simage\HW\Platform
    Under Platform we either have 2 types LT or DT. (laptop or desktop)
    What I want to do is at the top of my bat file have it search this key. If it has the value LT I want it to continue on with the script. If the value is DT I want it to not run the rest of the script and go to :end
    If this is possible can someone provide me with the commands to put at the top of the script with also the IF commands to continue or go to :end

    Thanks for you reply but I'm still a little lost with the reply.
    What is the rest of the commands?
    I understand this will query the registry, but what about searching for "LT or DT" and the IF/GOTO Commands?
    reg query HKEY_LOCAL_MACHINE\SOFTWARE\IS_DEPT\Simage\HW\Platform
    I think my confusion is how to define LT or DT as the variable. I keep finding %errorlevel%  variable, but that seems to only define on (1) or off (0)
    Here's what I have so far and I dont' think it's correct.
    reg query HKEY_LOCAL_MACHINE\SOFTWARE\IS_DEPT\Simage\HW\Platform /f
    if "%ERRORLEVEL%" == "LT" GOTO HOME
    if "%ERRORLEVEL%" == "DT" GOTO NOOOOPE

Maybe you are looking for

  • HP Officejet Pro L7780 - Network Letter Nightmare!

    Hello. I'm hopin somebody can help with a problem I am having with my HP Officejet Pro L7780: The printer is connected to my wireless network and all is well with this. The problem lies with the network letter that  it assigns itself to on my PC (Win

  • Blu-ray menu link not going to correct page

    Here we go again. I try something new, and it doesn't work. Here is the situation: I have a Blu-ray menu. The main page of the menu has three buttons: Play Movie, Scene Selection, and Bonus Features. Play Movie starts playing the disc at chapter 1, w

  • BI SAP Query Connector Heatmap Error - Empty display in Visual composer

    Hi, I am trying to create an Heatmap iview in SAP Visual Composer using BI SAP Query Connector. While using the Heatmap template, we are able to see the data but finally when we deploy  and run the iview we see empty screen. Any inputs is highly appr

  • BPM Work flow User escalation

    PROBLEM SUMMARY-_ How to achieve User escalation when we have User task with one Stage, 2 Sequential Participant blocks with one user in each block. DETAILED DESCRIPTION-_ In my user task I have a stage with 2 participant block configured sequentiall

  • Jdev 11g: Warnings in structure window for jspx (makeCurrent)

    Hi, Jdev 11g generates code in jspx page which causes warnings in structure window. jspx-code:                   <af:table value="#{bindings.VwBob0010Main0010.collectionModel}"                             var="row"                             rows="#