Task Scheduler task never ends

Morgan WHYMARK 1 Reputation point

Running a batch file through the Task Scheduler
Its running fine, completes everything expected
Then continues to run without end for no reason

Batch File contains:
-> "C:{PATH}\bin\runapp.cmd"

Runapp contains:
-> cd "C:{PATH}\"
-> java -cp {FILE NAME}.jar; {PACKAGE NAME}
-> exit /b

Maybe it is because my user is not an admin yet im trying to run with highest privileges:
If it was this, how could i get around this to allow the tas to run while user isnt signed in... i already tried using the admin account on the laptop!

The action appears as follows:

Java file it executes just creates a file, which its doing fine... But not ending the task, any suggestions?????

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
9,550 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,908 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Rich Matheisen 39,266 Reputation points

    Does everything work if you remove the "/B? switch from the DOS "exit" command?

    /B Specifies to exit the current batch script instead of CMD.EXE. If executed from outside a batch script, it quits CMD.EXE.

    1 person found this answer helpful.

  2. Rich Matheisen 39,266 Reputation points

    I don't see anything in there that has to do with PowerShell. Also, I'm not sure I understand what you mean to do with constructs like "cd "C:{PATH}\". Are you trying to access environment variables?

    C:\Users\richm>cd "C:{PATH}\"
    The system cannot find the path specified.

  3. MotoX80 25,771 Reputation points

    Batch File contains:
    -> "C:{PATH}\bin\runapp.cmd"

    So your scheduled task runs BatchFile.cmd which in turn calls runapp.cmd?

    Add the /c switch to the arguments so that cmd.exe terminates when the batch file completes.

    C:\>cmd /?  
    Starts a new instance of the Windows command interpreter  
    CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]  
        [[/S] [/C | /K] string]  
    /C      Carries out the command specified by string and then terminates  

    You should also capture stdout and stderr so that you can troubleshoot any execution messages.


  4. Morgan WHYMARK 1 Reputation point

    Answer Found in the end:
    -> my java was using a Java swing component called "JOptionPane.showMessageDialog"
    -> this wasn't closing preventing the file from closing