Windows task scheduler to run batch file running a java program

I have created a batch file that runs my SendEmail program. The batch file is in the same directory as the java program. The only line in the batch file is
java SendEmail
This works fine from the command prompt but from the windows task scheduler it fails to function. Any help on how I can overcome this problem will be greatly appreciated.
THanks

Looks okay. The classpath is set, too, I guess? Btw, try running javaw instead of java. I may err, but I think it can show a console, so you can watch any error messages.

Similar Messages

  • How can I execute a batch file from my java program

    Hi,
    Can someone help me or direct me to a link,
    How can I execute a DOS batch file from my java program?
    Thanks

    You will need to grab a handle to the process's
    outputstream so u can see its output.The OP didn't mention any output from any batch file;
    nor any input for that
    matter,so lets not complicate matters here for now
    ok?Actually I think this is essential to see whether it works or not. It's either that or do some manual check to see whether it ran, which is not exactly elegant, and in some cases this may not be easier than simply writing the output stream code, or in fact it may be impossible to check manually.
    I'm sure it wasn't intentional that your post appeared to be bristling with attitude.

  • Running Batch file thru a java program

    hai friends
    i have a batch file like hello.bat
    how can i run that batch file when i run my java program
    i heard that Runtime.exec() is used to run the batch files.
    can i use Runtime.exec() to run my hello.bat file or any other things i need to use ?
    Thankyou VeryMuch
    Yours
    Rajesh

    Yes, you can use Runtime. You should look it up in your API guide, but this code might get your started:
            try
                Process p = runtime.exec("command.com /c c:\\hello.bat");
            catch(IOException e)
                System.out.println("Failed");
            }Your API guide will explain how to get a Runtime object. The syntax is very straightforward.

  • Making batch files to execute java programs in windows

    In my comp sci class, i found a folder with a batch file, an application file, and all class files necessary to run the program.
    how do i take my java program and make a batch file to run it (in dos) like that program in my comp sci class?

    Okay, here are your steps for running a java program from a batch file:
    1) Open Notepad
    2) type the following:
    set JAVA_HOME=C:\j2sdk1.4.0_03 // specify the path where your jdk is
    set path=%JAVA_HOME%\bin;.
    javac {-classpath .;one.jar;two.jar} YourProgramName.java
    java {-classpath .;one.jar;two.jar} YourProgramName
    The stuffs inside {} is not necessary if your program doesnt use any .jar files.
    3) Save the notepad as mybatch.bat in the directory where your Java program is located.
    4) In the DOS prompt, go to the directory where you have .java and .bat files
    (use 'cd' command)
    5) Now, type mybatch.bat and press ENTER.
    Thatz it. Your program runs like a charm now!!!
    (provided the compiler is pleased with ur code :)
    -- layman's pal

  • How to invoke the .bat(batch file ) from the java program

    i want to run some commands when i run one java program.
    I wrote those dos commands on the batch file and i want to include the bat file in the java program so that i can execute the bat file when i run the java program.
    tell me the way that i can run my bat file inside the java program.

    i tried this :
    a .bat file named test.bat, with this code : copy test.bat test2.bat
    a java class, Test.class, in the same directory
    public class Test {
         public static void main(String[] args) {
              try {           
                   Runtime rt = Runtime.getRuntime();
                   Process proc = rt.exec("cmd /c test.bat");
                   proc.waitFor();
                   int exitVal = proc.exitValue();
                   System.out.println("Process exitValue: " + exitVal);
              catch (Throwable t) {
                   t.printStackTrace();
    }

  • Windows task scheduler not running

    Hi All!
    (First of all, sorry for my poor english!)
    I have a couple of windows servers 2008 R2 Enterprise SP1 on my company and one of them doesnt work like it should and was instaled from zero last week.
    I create a bat file to do some stuff and because it dosnt work, for test porpouses i made a bat file realy simple, that wirtes file
    Here is the bat file code:
    echo "text_example" > C:\scripts\works.txt
    my user has write permisions and the task is configured to run with my user.
    If i run my bat manualy works fine.
    If this job is set to the task scheduler  "run only if user is loged" also works fine
    BUT when i set the task to run wheter "the user is logued or not" and I log off and return after the job was triggered, i found that the last run date is the one i set but the last run result is (0xc000142) and the task ovbiusly didnt work. 
    Im figthing with this problem las 4 days and i cant find why is this appening (its trange that in the other servers in the same group works fine)
    Here is the task code:
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2014-11-17T14:07:58.9325949</Date>
        <Author>GROUP\rrepetto</Author>
      </RegistrationInfo>
      <Triggers>
        <CalendarTrigger>
          <StartBoundary>2014-11-17T17:46:00</StartBoundary>
          <Enabled>true</Enabled>
          <ScheduleByDay>
            <DaysInterval>1</DaysInterval>
          </ScheduleByDay>
        </CalendarTrigger>
      </Triggers>
      <Principals>
        <Principal id="Author">
          <UserId>GROUP\rrepetto</UserId>
          <LogonType>Password</LogonType>
          <RunLevel>LeastPrivilege</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>false</WakeToRun>
        <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
        <Priority>7</Priority>
      </Settings>
      <Actions Context="Author">
        <Exec>
          <Command>C:\scripts\test.bat</Command>
        </Exec>
      </Actions>
    </Task>
    Any help will be greatly appreciated !
    Thanks In advance!
    Ramiro

    Since batch job can be run manually without error, cmd.exe is not the problem.
    I researched and found that the problem may be due to exhausted desktop heap and the solution is to increase the value.
    Please try this step:
    1. restart the server first and test again (a simple solution that may work)
    2. if the first attempt fail, take a full backup first and attempt to increase desktop heap
         http://www.symantec.com/business/support/index?page=content&id=TECH48099
    Yes THAT WAS THE SOLUTION FOR THE ISSUE. !!
    Now its working perfect!!
    Why now its working and not before? Because after made the changes to the registry,
    RESTART IS NECESSARY to apply the changes and I have done it yesterday night (this server is working 24x7, so its hard to find a moment to restart it). 
    Thanks for all to help me with this issue!!! I really,really ,really ,really  apreciate !!! 
    THANKS !!!!!

  • How to create a batch file for a java program?

    I have a java project in JCreator and the project is organised into packages. I have also configured JCreator to provide 2 arguments to the main method when the project is executed.
    I would want to create a batch file (.bat) for this project where the batch file can automatically use the arguments set in JCreator when the program runs.
    How do I go about creating the batch file?

    where the batch file can automatically use the arguments set in JCreatorThat all depends JCreator... can you get those arguments somehow?

  • RUNNING PHP SCRIPT WITH ZEND FRMWRK IN WINDOWS TASK SCHEDULER

    I have a PHP script which includes the Zend framework Mail.php for sending mails.
    I am running a WAMP server and i used DW to create it.
    I want to run my script in every 5 mins, How i can schedule it in Windows task scheduler.
    I tried running a bat which contains the php.exe path and arguments as php file but it gives an error that zend/mail.php not found.
    Please help its really urgent.

    Thanks for your response.
    bat file has:
    path of the php.exe -f path of php file.
    But when it runs it gives an error that the zend framework file not found.
    I have a seperate PHP includes folder under which zend FW is stored.
    That folder is marked in includes_paths in php.ini.

  • Running a java program via a batch file

    I am unable to run a java program from a batch file that I created.
    spiderpackage.EntryPoint is a class file which I am trying to run with a -v option to output something.What should I do to get the output?
    echo ^<html^>^<body^>
    echo hello^<br^>
    call java spiderpackage.EntryPoint -v
    echo ^</body^>^</html^>

    This has nothing to do with java programming. Have a look at the windows help for the call command.
    The echo <html> stuff doesn't make sense. What's it for?
    The command in you batch file should be:
    java -cp . spiderpackage.EntryPoint -v
    assuming that java is in the system path, and the EntryPoint.class is in a directory called spiderpackage which is a subdirectory of your current working directory

  • Can we run the batch file using simple java application

    Hello sir,
    we want to run the batch file using simple java application. i tried with some example, we run the exe files but not batch file.
    Runtime r = Runtime.getRuntime();
    r.exec("D:\\jboss\\bin\\run.bat");
    My application is server will run when we run the java appliation.
    any suggestion? plz give me the solutions

    yes you can run html file
    WEB.SHOW_DOCUMENT is a built-in that is used in Forms to call URL from a Web Form. It works much like the similar way that a link on an HTML page works and it takes two arguments, one is URL and second one is TARGET, in your case use following.
    WEB.SHOW_DOCUMENT('http://channas.iil.informatics.lk:8890/forms/frmservlet?config=abc.html', '_blank');
    Hope this will work for you
    Abbas

  • Windows Task Scheduler executing old triggers even after recreating the task

    I had this task working perfectly until I changed the schedule. After I changed the scheduled time 5 minutes earlier, I noticed that in the history, it still triggers the old schedule. I tried restarting the server, deleting the task and recreating it even
    without a trigger and it's still executing the task with the old trigger. The attached screenshot shows that the task doesn't have a trigger but as you can see in the history it's still trying to execute the task. How does the Windows Task Scheduler work?
    Is there a file or database that I can purge the old task?
    I also tried applying this hotfix but it didn't seem to fix the issue: 
    http://support.microsoft.com/kb/2461249
    NOTE: This is Windows 2008 R2 and the Error message in the history is: Task Scheduler failed to start "<the
    name of my task>" task for user "<the
    user>". Additional Data: Error Value: 2147750689.

    Since batch job can be run manually without error, cmd.exe is not the problem.
    I researched and found that the problem may be due to exhausted desktop heap and the solution is to increase the value.
    Please try this step:
    1. restart the server first and test again (a simple solution that may work)
    2. if the first attempt fail, take a full backup first and attempt to increase desktop heap
         http://www.symantec.com/business/support/index?page=content&id=TECH48099
    Yes THAT WAS THE SOLUTION FOR THE ISSUE. !!
    Now its working perfect!!
    Why now its working and not before? Because after made the changes to the registry,
    RESTART IS NECESSARY to apply the changes and I have done it yesterday night (this server is working 24x7, so its hard to find a moment to restart it). 
    Thanks for all to help me with this issue!!! I really,really ,really ,really  apreciate !!! 
    THANKS !!!!!

  • Windows Task Scheduler does not execute .vbs script as exptected while using CScript.exe

    We have a .vbs script that reads a source text file, looks for errors, performs a find/replace and then writes a cleaned version of the file to a destination folder.
    When executing the script by manually double clicking on the .vbs file, the script works flawlessly.  But when executing via Windows Task Scheduler using Cscript.exe, it creates an empty, zero byte, text file.  Task Scheduler is set to run
    "C:\Windows\System32\cscript.exe" with the Add arguments (optional): C:\Scripts\myscript.vbs.
    Does anyone know of a way to make it work using the Windows Task Scheduler?
    Part of the Script:
    Sub CheckFilesIntegrity()
    Dim cleanedfile,strLine,outputStr, tempstr, tmpChar, changeTo, companycode, storestring
    Dim ObjFileSys, objFile,objCleanFile
    charArray = Array("-","?", "/", "\", ":", "*", """", "<", ">", ",", "&", "#", "~", "%", "{",
    "}", "+", "_", ".", "a", "e", "o", "s", "h","i","E", "O","P", "S", "p", "=")
     Set ObjFileSys   = CreateObject("Scripting.FileSystemObject")
     Set objCleanFile = CreateObject("Scripting.FileSystemObject")
     Set objFile = ObjFileSys.OpenTextFile(file.name, ForReading, True)
     textfilename = destinationpath & objfilesys.GetBaseName(file) & ".txt"
     Set cleanedfile = objCleanFile.OpenTextFile(textfilename, ForWriting, True)
     ObjLog.writeline "File containing cleaned up data: " & textfilename
     Do while not objfile.AtEndOfStream
         strLine = objfile.ReadLine()
         tempstr = strLine
         If (Left(UCase(tempStr),8) <> "HPAYMENT") Then
          'fix pay now data entry whre record does not have a company code
          If Mid(tempstr, 18,3) = "000" Then
           companycode = Mid(tempstr,32,3)
           storestring = Left(tempstr,17)
           tempstr =Replace(tempstr,"000",companycode,18,1,1)
           tempstr = storestring & tempstr
           storestring = Left(tempstr,31)
           tempstr= Replace(tempstr,companycode,"000",32,1,1)
           tempstr = storestring & tempstr
          End If
          'remove invalid characters and replace them with zero (filler)
       For Each tmpChar in charArray
        Select Case tmpChar
         Case "-","?", "/", "\", ":", "*", """", "<", ">", ",", "&", "#", "~", "%",
    "{", "}", "+", "_", ".", "a", "e", "o", "s", "h","i","E", "O","P", "S", "p", "="
         changeTo = "0"
         outputStr = replace( tempstr, tmpChar, changeTo,1,-1,1 )
        End Select
        tempstr=outputstr
       Next
      Else
       outputStr = tempstr 
      End If
        strLine = outputStr
      cleanedfile.writeline(strLine)
     Loop
     cleanedfile.Close
     Set cleanedfile = Nothing
     Set ObjFileSys = Nothing
     Set objFile = Nothing
     ObjLog.writeline " Completed processing of file: " & textfilename
    End Sub

    So we ended up getting it to work by replicating the double click function.  Meaning that we created a Batch file that calls the .vbs script, then had Windows Task Scheduler run the Batch file.  In that way all necessary permissions were passed
    through from one environment to another, which was failing when we called the .vbs script using CScript.

  • VBS objshell.AppActivate doesn't work with Windows Task Scheduler

    Hi all,
    This script do the following : 
    Open Adobe Flash media Live Encoder with an encoding profile
    Activate the Adobe Flash... Window
    Send enter key to start encoding
    Set objShell = WScript.CreateObject( "WScript.Shell" )
    objShell.Run """C:\Program Files (x86)\Adobe\Flash Media Live Encoder 3.2\FlashMediaLiveEncoder.exe"" /p ""C:\Users\process\AppData\Roaming\Adobe\Flash Media Live Encoder 3.2\profile.xml"""
    'Loading time
    WScript.Sleep 5000
    objshell.AppActivate ("Adobe Flash Media Live Encoder 3.2")
    WScript.Sleep 5000
    objShell.SendKeys "{ENTER}" 'start encoding
    This script perfectly works manually, but the objshell.appactivate command doesn't work when i run it with the windows task Scheduler.
    Any ideas ? Thx

    Hi to all! I have found workaround for this issue - I wrote vbs, made run it via bat file, and converted the bat file to exe
    vbs
    Set oShell = CreateObject("WScript.Shell")
    If oShell.AppActivate ("Connecting error to Bee") Then
    WScript.Sleep 2000
    oShell.SendKeys "%{F4}"
    End If
    bat
    start C:\Users\User\Desktop\close.vbs
    bat to exe
    Advanced BAT to EXE Converter v2.83
    I know it's some weird solution but it is working with Win Task Scheduler correctly. Try it ;)
    In some cases you need to mark checkbox "run this program as an administrator" and (or not) disable UAC.

  • Error when using Windows Task Scheduler in C#

    I am using Windows Task Scheduler in my Visual C# application. I add the reference to C:\Windows\SysWOW64\taskschd.dll (on a 64-bit system), and Visual Studio creates a COM wrapper Interop.TaskScheduler.dll. Ths works fine on Windows 7. However, when
    I run on Windows 8.1, I get the following error:
    Unable to cast COM object of type 'System.__ComObject' to interface type 'TaskScheduler.IExecAction'.
    This operation failed because the QueryInterface call on the COM component for the interface with IID
    '{4C3D624D-FD6B-49A3-B9B7-09CB3CD3F047}' failed due to the following error:
    No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
    I noticed that on Windows 7, the above GUID exists in the registry under HKEY_CLASSES_ROOT\Interface, with the value "IExecAction". But on Windows 8.1, there is no such GUID, and no key with value "IExecAction". I use IExecAction
    in my code.
    When I develop on Windows 8.1, the program compiles, but at runtime I get the above error.

    Hello tomszms,
    Here is a blog related to this issue and the troubleshoot steps of his error is very useful for your case, so please check for it:
    http://blogs.msdn.com/b/smondal/archive/2012/10/02/unable-to-cast-com-object-of-type-system-comobject-to-interface-type-microsoft-visualstudio-ole-interop-iserviceprovider.aspx
    Please try use the same way to track the logs and then try use the regsvr32
    on your Win 8 machine to re-register that dll and see the result.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Issues with Windows TasK Scheduler

    Hi!
    I'm having two issues recently with Windows Task Scheduler, and I'm wondering if anyone else has experienced this and know of a resolution. We are on Windows Vista.
    Error value 2147750687 - The task we are using has been running successfully since day one, all of a sudden, two concurrent jobs got triggered the other day, thus one of them failed and gave us this error. Why would the scheduler kick off two jobs start at the same time? How can that happen? The settings are "run with the highest privileges" and run whether user is logged on or not".
    Error value 2147549186 - On this one, the task was running as scheduled, no errors in the log, then all of the sudden, after 10 minutes into the job, it re-started “due to a failure”. The settings are set to restart after 5 minutes, 3 attempts, but since it was running, and our logs do not identify any issues, what could have caused the scheduler to think there was an error?
    Joe

    Hi LordTim,
    >>However, I cannot get Access to load<<
    How did you load the Access? Did you use Access object to automate the Access applicaiton?
    If I understood correctly, did Access load successfully when you in a normal script?
    If yes, I think the issue may relative to the Task Scheduler. I suggest that you get more effective response from
    Windows Community forum about Task Scheduler issue.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for