Task Scheduler task never ends

Anonymous
2022-04-19T06:49:02.483+00:00

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!
194327-image.png

The action appears as follows:
194339-image.png

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.
12,408 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.
5,429 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Rich Matheisen 45,416 Reputation points
    2022-04-19T18:07:03.7+00:00

    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 45,416 Reputation points
    2022-04-19T14:41:24.67+00:00

    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 32,441 Reputation points
    2022-04-19T16:11:03.997+00:00

    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.

    194338-capture.png


  4. Anonymous
    2022-04-19T18:11:09.24+00:00

    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