Scheduled task won't run .bat file

Hi. On Windows Server 2008 I have a scheduled task that calls a .bat file. The fist step in the .bat file is write to a log file to the same directory in which the .bat file exists. This allows me to find out if it is ever run. When the .bat file is run from a command prompt it runs as expected writing to the log file and completing its actions. My problem is that when I run the scheduled task manually or allow it to run when scheduled it appears to run but the .bat file is never run. No log file is ever created. The History tab in the properties of the scheduled tasks shows the task being started and running then completing with an operation code of 2. I've disabled the UAC for the user account. I've set the task to run as the Administrator user and verified the permissions for that user. I know the password is correct for the task because I can make changes to the properties and save those changes with the username/password. I'm at a loss for further troubleshooting steps. Can anyone point me in the right direction to figure out why these .bat files are not being run? 

So I had this problem, I double clicked on the .bat and notepad opened the .bat.  I ran through this whole long and very absorbing thread of this forum.   I wanted to save the entries that were most helpful, so I copied and pasted into
a notepad document (.txt)  I could not find a way to attach it here, so I copied and pasted that below. I called it a synopsis....  Did I spell that right?
As you can see, I added my experience at the top (A and B).  The stuff I copied is noted with the original author. This is the first time I posted anything to these here microsoft forums, although I have been telling computers what to do for 40+ years. 
So hope I did not break any social protocols here.
==================================== Begin ====================================
     Running A Dot Bat File in Windows Server 2008 Vista 7 etc and beyond V01
============================================================================
This was created as a synopsis of the entries at the following forum location:
http://social.technet.microsoft.com/Forums/en/winservermanager/thread/d47d116e-10b9-44f0-9a30-7406c86c2fbe
A) manually
     This is an opinion added by Thomas Rock
    1) Open a command window (that would be cmd.exe)
    2) In the command window navigate to the directory containing the .bat file and it's dependents
           ex...  C:\Program Files (x86)\Bobs\Your\Uncle
    3) Run the .bat file by typing the name including the .bat extension (in the command window of course)
             TheBatFile.bat
       Note: Using this method, the .bat file will run in the current command window directory (the directory where the .bat file is located)
                         (this is the key for getting it to run in the task scheduler... Start in folder option)
B) The double click
            This is an opinion added by Thomas Rock
     1) Using Windows exlporer, find the .bat file
     2) use the mouse or other device to double click on the .bat file
     3) if it does not run (in my case the wordpad application opened the .bat file)
          a) make sure that the .bat file extension is associated with the program c:\windows\system32\cmd.exe
          b) make sure the profile you are using has rights to run the cmd.exe
          c) make sure the profile has the rights to the directories, the .bat and any other objects used or affected by the .bat file processing.
C) As a task using task scheduler
     Proposed As Answer by Brian Vandemark Wednesday, September 02, 2009 9:36 PM
1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file:
      a) open the task properties
      b) click on the "actions" tab
      c) click on the action and then the "edit" button at the bottom. 
      d) In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
      e) be sure to include an end backslash for the start in path "C:\dir1\dir2\"    (the last backslash is not optional)
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things:
      a) the .bat file itself
      b) the folder containing the .bat file
      c) the target files/folders that are affected by the .bat script. 
           Note:  Inherited permissions did not seem to work.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) Tick the box "Run with highest privileges".    
       Note: Point 6 here was from Edson F. Lima Wednesday June 30 2010 1:35 PM
                  The original point 6 was moved to point 7.
7) The Task should run successfully with expected output when you right-click on the task and select "run" 
        If it does that then it will run successfully when you are logged off.
D) Still another way as a task using task scheduler
      Proposed As Answer byDarren Wallace Thursday, July 15, 2010 1:41 AM
This has been bugging me for 6 or 7 months.
I don't have admin rights to the box and the guy who does is very busy...
so I've felt the range of emotions mentioned above.
I tried most everything above as well. But what seemed to get my processes processing, was ...
   • on the General tab, I clicked the Change User or Group button
   • in Select User or Group (first smaller dialog box)  I clicked the Advanced... button
   • in the next Select User or Group (second bigger dialog box) I clicked the Find Now button
   • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
   • then I clicked OK and returned to the General tab above
   • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
   • then I made sure that the Run with highest privileges was checked
   • then I clicked OK and during the next scheduled time to run ... it ran
   Note: See note in A) Manually above.
E) Task scheduler recommendation
     Proposed As Answer byTamusJRoyceThursday, December 01, 2011 3:42 PM
I have found .bat and .cmd files do not run correctly either.
    My solution:  Don't run the batch file directly. 
       Have TaskScheduler run:  cmd.exe
          with parameter:  /C YourBatchFile.bat
         and start in: C:\SomePath\ (without quotes!) where C:\SomePath\YourBatchFile.bat exists. 
        And then select the radio button for it to run regardless if you are logged in or not.
Exit errors may not be logged to the Event Log (they weren't when the .bat ran directly from Task Scheduler when I was logged in), so I find it best to manually log your own Event in case a error occurs and you want to send an email.
 REM Logs an event which causes eventlog to send an email when it fails.  Also, "/l application" needs to be lowercase.
eventcreate /t error /id 203 /l application /d "your logged description."
And then make a completely separate task with a trigger:  On an event.  Basic Selected.  Log: Application.  Source: EventCreate. Event ID: 203.  And have the action on this task send an email (attaching any generated log files, if needed).
Hopefully helpful (took me 3 days to figure all this out...gar)
===================================== End ===================================
     Running A Dot Bat File in Windows Server 2008 Vista 7 etc and beyond V01
============================================================================
 

Similar Messages

  • Running bat files in java code

    Hi,
    I am trying to run a .bat file within java code like this.
    Runtime.getRuntime().exec("c:\\Test.bat");
    but no success. Could you please suggest how to run .bat file or simply a
    DOS command from java code.
    thanx in advance
    Deepak Garg.

    try this...
    n reply whether it worked or not......
    import java.util.*;
    import java.io.*;
    import java.net.*;
    try
    Runtime runtime = Runtime.getRuntime();
    Process process ;
    process= runtime.exec("./temp_install");
    //code to print command line replies
    InputStream stderr = process.getInputStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while((line=br.readLine())!=null)
    System.out.println(line);
    catch(Throwable t)
    t.printStackTrace();
    }

  • Running Bat file in Minimized Mode

    Hai All,
    I need to run bat file using Runtime, Bat file should run in minimized
    mode ...
    any one help me
    Regards
    Yuva

    Assuming it's windows...
    start /min mybatchfile.batOpen a command prompt and type "start /?" to see the params available.
    regards,
    Owen

  • How to write run.bat files

    Can anyone tell me how to write run.bat files to run java classes. Currently my run.bat file has the following two lines,
    c:\j2sdk1.4.1_02\bin\javac.exe *.java
    c:\j2sdk1.4.1_02\bin\java.exe questionnair
    But the class is not executed. Thanks in advance.

    you'll have to provide more details.
    Firstly, which package is the class a part of? and secondly, where on the filesystem is the root of the package?
    You might also benifit from placing the c:\j2sdk1.4.1_02\bin\ into the classpath.
    On a rainy day, check out the ANT tool, it will take care of all that crapola for you.
    newio

  • Help! problem running .bat files in browser

    HI! Hope you can help me!
    I have a simple applet that runs .bat files and retrieves the resulting information into a text box.
    To run those files I use:
    Runtime rt = Runtime.getRuntime();
    Process processo=rt.exec("C:/po2PrtMonitor.bat 04600105 ope >C:/infoPrt.txt");
    in wich "04600105","ope" and ">C:/infoPrt.txt" are parameters that the .bat file is expecting. When the file is ran it saves the resulting information on a simple .txt file, that I later read by using:
    fichResposta = new FileInputStream(fichRespostaPath[0]);
    When I run my applet on JDeveolper 9.0.2.822 is works perfectly, the problem is when run it on the browser.
    On the browser the applet executes the file by opening a MS-DOS prompt and when it finishes executing the file, the prompt closes automatically and doesn't send the information into the .txt file.
    My .bat file is something like:
    jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 %1 %2 %3
    where %1,2%,3% are the above parameters given by the applet when the file is ran.
    If I run it on JDeveloper I get:
    C:\>jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 04600105 ope
    PRTSES=04600105 HDR=0460010000000005 STA=OPENED TRF=ACTIVE TRP=CONN ILTS=15 Long postings are being truncated to ~1 kB at this time.

    Here is what is missing:
    ILT=0 MSQ=388 HDR=04.60.01.00.00.00.00.05.41.00.01.84. CMD=STRT-TRF
    When the applet is run on the IE broser what I get is simply:
    jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 04601005 ope
    I have no idea as to what the problem might be! Do native methods work differently on the browser?! Could it be a problem on the deployment? A library not included on the deployment profile? Suggestions are very welcome.
    Hugo Rosas

  • Certain scheduled tasks do not run anymore after DST change

    Hi everyone,
    I noticed a problem on Server 2012 after daylight savings time was set effective last weekend in March. All scheduled tasks that are configured to run weekly on Monday through Friday don't run anymore! Tasks that are configured to run daily are OK. Shall
    I really put a wrapper script around the executable to check the weekday myself??? Another solution to work around this bug seems to be to set the start day after DST change day, then the weekly Jobs also run OK again.
    Many Greetings
    Michael

    We have experienced the same issues.  Just to put some more information out there (and confirm some points from above):
    We run 12 scheduled tasks on 2 servers.
    Machines are "Microsoft Windows Server 2012 Standard", ver. 6.2.9200 build 9200, HP ProLiant BL460c Gen8
    4 scheduled tasks did fine over the DST switch in March
    8 scheduled tasks failed to run
    All scheduled tasks that ran were set up with
    “Configure For” = “Windows Server 2012”
    All scheduled tasks that failed were set up with
    “Configure For” = “Windows Vista™, Windows Server™
    2008”.
    All scheduled tasks, both affected and unaffected, were scheduled as Weekly, Mon-Fri.
    Changing the "Configure For" field after the tasks failed to run did NOT fix the problem.
    Changing the time of a task after the task failed to run did NOT fix the problem
    Changing the "Start" date of a task after it failed to run DID fix the problem.
    Given that there are not a whole ton more complaints out on the web about this bug, it must be that the bug does not affect every instance of the scheduler on Windows Server 2012.  In other words, it must be only some particular configuration
    of Windows Server 2012 that causes this bug, otherwise surely there would be many many more complaints.  Can people who are experiencing this bug check and post configuration info so perhaps we can determine a common factor?  Thanks.

  • Running .bat files as administrator on win 7 and win 2k8 machines

    I have .bat which will be copied onto Win 7 and Win 2k8 machines remotely. The batch file contains scripts to stop and restart Windows services, like,
    net stop "Adobe Acrobat Update Service".
    Now when I run this batch file, I get "System error 5 has occurred. Access is denied."
    I understand that I need to run this batch file as administrator (here by administrator I mean, Windows default administrator.).
    Does anyone have a solution for this?
    P.S: 1) "run as" command inside the .bat file won't work, since you need to run the .bat file itself as administrator (here by administrator I mean, Windows default administrator.).
    2) I can create another batch file (say b.bat) containing the "run as" command and invoking the the original batch file (say a.bat), which has the command net stop "Adobe Acrobat Update Service". But still, this won't solve the issue, since you can run as,
    the user, who has administrator privileges and not run as administrator (here by administrator I mean, Windows default administrator.) itself.

    Suhas,
    Can you explain me why you want to do this?
    Maby there are there some beter ways to achive your goal.
    The reason why this doesn't work is UAC who strips the administrator tokens from your user account.
    So it is not nesseary to use the default windows administrator account. Just a user with administrative priviliges will do you only need to run this command elevated.
    There are several ways to run this command elevated:
    Just right click on the batch file and choose the option run as administator.
    Quite simple but a no go if you wanna have a fully automated solution
    Use PsExec.exe  from the pstools suite (avaible
    here)
    If you use the command like this:
    PSEXEC -u domain\user -p password -h net stop spooler
    PSEXEC -u domain\user -p password -h net start spooler
    Or from a remote machine (pcX = remote management machine, pcY = machine where you want to restart the service.)
    Execute this command on machine pcX:
    PSEXEC \\pcY -u domain\user -p password -h net stop spooler
    PSEXEC \\pcY -u domain\user -p password -h net start spooler
    Create a sheduled task with the "highest privlilges" that executes your batch file.
    etc ...
    Kind Regards
    DFT
    IM me - TWiTTer: @DFTER

  • KM Scheduler Task is not running...

    Dear All,
    I have created a KM Scheduler Task using the NDWS Wizard. I followed prakash's blog (http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1515). My doubt is where exactly the attributes are created? and can any one guide how to create the attributes in .cc.xml file. And how does public void run( String id, Properties properties ) it works?
    The application was successfully deployed. I am able to see my task under System Administration->System Configuration->Knowledge Management->Configuration->Content Management->Global Services->Scheduler Tasks.  but I think it is not running. Can any one give some clue on this. As i'm not finding any thing uder Kmcontent>Documents.
    Do i need to configure anything to run KM scheduler Task?
    Thanks and Regards,
    JAGAN.
    Edited by: Jagan456533 on Jan 19, 2011 11:10 AM

    Hi Jagan,
    The status "0" for your task in "Component Monitor" is fine.
    Navigate to System Administration> System Configuration>Service Configuration. You can see here Applications and Portal runtime.
    Open Applications--> and you Task. Right click on your task folder and say Administrate. Here you check whether your task has been stopped, running. Make sure its running. ( Try refresh, if its already running ).
    In you task folder, you will see "Service Folder"  under this, you will see "RFServiceWrapper", right click on it and say configure, make sure the values are like shown below:
    Name : http://sapportals.com/xmlns/cm/sch
    Value: Value1
    Also make sure in your portalapp.xml, the values are same:
    RFServiceWrapper
    service-config
    className= com.sap.netweaver.rf.wrapper.RFServiceWrapper
    startup= true
    service-profile
    Name= = http://sapportals.com/xmlns/sch
    Prof= Value1
    You see tha the same name is used "Value1" in RFServiceWrapper both in portalapp.xml and in Service Configuration.
    You can use any other name but the it should be same in both the places.
    Make all these changes, and then restart your task in Service configuration again. Any changes in portalappl.xml, restart is necessary.
    Kind Regards,
    Poornima

  • Running bat files from JDeveloper

    hi
    Sometimes it could be convenient to run a bat file directly from JDeveloper.
    For example, the application in SQLAuthenticatorApp-v0.02.zip (see also forum thread "how to disable (or lock) users") has an Ant file BuildStuff/build-wlst.xml which has targets like "wlst.create-domain" and "create.wls-start-stop-bat-files", the last one resulting in some bat files which I have been able to configure to run from JDeveloper,
    see http://www.consideringred.com/files/oracle/img/2011/run-using-cmd-20110529.png
    The External Tool cmd configuration I use is shown in the screenshot
    at http://www.consideringred.com/files/oracle/img/2011/external-tool-cmd-20110529.png
    See also the blog post by John 'JB' Brock
    at http://blogs.oracle.com/jdevextensions/entry/how_to_extend_jdeveloper_without_writing_code
    - (q1) How can I configure the External Tool cmd to run in its own cmd (command) window outside JDeveloper?
    many thanks
    Jan Vervecken

    Hi Jan,
    It looks like this is going to be a bug from what I can see. After looking at it a little more this morning, not only does it not display the cmd window, but if you use the /k argument, it leaves the script running in memory. Look at your Task Manager after running a few times with /k
    I'll file a bug, and see if anyone has a work around or something that I missed.
    For now, it would appear this is not possible, and you will just have to see the result in the log window. I would not use /k as well. Stick with /c for now.
    Sorry for the inconvenience.
    --jb                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Run .bat file?

    Alright this won't seem to run my file, what am I doing wrong?
    try {
                String File = "mybat.bat"; // File specified
                Runtime.getRuntime().exec(File);
            } catch (IOException ioe) {
                ioe.printStackTrace();
            } Thanks for any help.
    Edited by: Austin187 on Nov 5, 2008 2:30 PM

    .bat file will run without "/c", but here's what I was talking about
    private static void SlashCTest() {
              while (true) {
                   JFileChooser jf = new JFileChooser();
                   int res = jf.showOpenDialog(null);
                   if (res != JOptionPane.OK_OPTION) System.exit(0);
                   File f = jf.getSelectedFile();
                   Runtime r = Runtime.getRuntime();
                   //String cmd = f.getAbsolutePath();
                   String cmd = "cmd.exe /C \"" + f.getAbsolutePath() + "\"";
                   try {
                        Process p = r.exec(cmd);
                        InfoFetcher fetcher = IOUtils.loadData(p.getInputStream());
                        FetcherListener fl = new InfoFetcher.ToStandardOut();
                        fetcher.addFetcherListener(fl);
                        new Thread(fetcher).start();
                        fetcher = IOUtils.loadData(p.getErrorStream());
                        fetcher.addFetcherListener(fl);
                        new Thread(fetcher).start();                    
                   }catch (IOException ex) {
                        ex.printStackTrace();
         }Edited by: tjacobs01 on Nov 5, 2008 11:39 PM

  • Scheduled task going to running state in OIM

    hi all,
    After running the Target reconciliation it is going to running state ....how to fix this?
    Thank you.

    For how much time it shows Running status ?
    Check the status of schedule task using http://localhost:7001/xlScheduler if OIM is deployed on weblogic on 7001 port.
    I have seen couple of clients who are using OID connector and never heard such issues in OOTB connector.
    Try with restarting the server.

  • Running .bat files from java applications

    Has anyone tried to run a .bat file from a java application?
    I know I can run java commands by getting the application's runtime, but I've a number of *.bat files I like to run from the application without having to extract the commands from the .bat files.
    thks,

    Crikey! You were answered very shortly after you posted your question, and you STILL haven't bothered to come back. And are you going to create a new userid the next time you ask a question, since bat2004 seems tied to this particular question?

  • Running bat-files from Java

    Hello,
    I have been trying to launch a bat-file from my Java code, running under windows, but with no success.
    Here is my simple code:
    Runtime.getRuntime().exec(new String[] {
             "C:\\temp\\test.bat"
          });This does nothing at all and generates no exception. Any suggestions?

    It seems java has a real problem with this... if you
    want to run another java program, for instance, you
    cannot do that either with String cmd="cmd.exe /C
    java myProgram"
    I need to pass parameters from one program into the
    program I'm going to open using java, that is why I
    need to call it from my first program. It can open
    executables and shortcuts, but has a real big problem
    doing things with the command line.No it doesn't have a problem with it. You just must be doing something wrong. By the way, since "java(.exe)" is already an executable, there's little value in wrapping that by the "cmd.exe" shell (unless you want to use the command shell for some reason such as passing the redirector (>) symbols to it to let it redirect stdout / stderr to a file)

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

  • Where is the run.bat file?

    Hi,
    I have downloaded beanbuilder-0_6-alpha from https://bean-builder.dev.java.net/
    I am trying to install the bean builder going thru the readme file. I have extracted all the file but I cannot find "run.bat". Can anyone help me find this file.
    If this is not how I should go about installing the bean builder. Please guide me.
    Thanks,
    tick_tick

    Hi,
    You probably have the wrong classpath on your line:
    java -cp ... javafilename xml ruleset_nameSince the DocumentBuilderFactory can't be found.
    It is most likely included in one of the jar-files in the lib directory.
    /Kaj

Maybe you are looking for

  • How do I get a "Details" display--as the default--when downloading a file, in the "Enter name of file to save to..." dialog box?

    When I receive an attachment to an email, and I click it and select "Download", I get the "Enter name of file to save to..." dialog box (because I already set the option to "Always ask me where to save files." But the file display always defaults to

  • Back to Back Print

    Hi, I am working with a smart form,now i  have table on page 1,but when the data is more in table,it print the data on second page,now i want to print the data at the back page only,as max my data can vary to page 2,I have changed the print mode of p

  • LC credit release  through vkm3

    Dear Brothers, My LC document is worth 5 millions ,after reaching that amount  the sales orders are gettings blocked,BUt once a new sales order is created suppose for 5.5 million it is blocking me at the delivery note creation level which is correct,

  • JMS Binding: in/out message

    Hi there, Could anyone help with the following problem I'm facing with? The problem is, the JMS Binding Component complains about the JMS MapMessage it received from a queue that was sent by an application client. Since the WSDL operation is in/out,

  • Designer 6.0 Client Installation

    Prior to the installation of Designer on my workstation, I had Forms60 working fine. After I installed Designer and rebooted my machine, it could not find WIN.COM; the autoexec.bat was modified by the Installer. I can't execute any of my *.fmx, it ju