The task scheduler does not start the Bat file

advertisements

My bat file is:

 @echo off
 java -cp * MyTimerTasker

I try to run main function in MyTimerTaskerClass. All jars and bat file are in same folder. When I try to run bat file with double click, it runs. When I try to run with right click and run as administrator, command window shows and disappears but my main function does not start. When I try to run with task scheduler, it never starts.

Edit: My main class.

 public class MyTimerTasker {
 public static void main(String[] args) throws IOException {
    FTPDownloadFiles ftpDownloadFiles = new FTPDownloadFiles();
    System.out.println("Running ...");
    DatabaseTask databaseTask = new DatabaseTask();
    databaseTask.connectToDatabase();
    ftpDownloadFiles.downloadFiles();

    try {
        databaseTask.parseFiles(JdbcConnection.filesPath);
    } catch (SQLException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        try {
            databaseTask.closeConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }

}
}


You are adding the classpath of all the files in the working directory. You should add the name of the jar to the classpath.