Bat file with log file but not able to execute with java program log file is not generation

  admin, batch-file, eclipse, java, windows

I created one bat file in that I am trying to copy folder and generate its log into myLog.txt file
Now I am trying to run the bat file through the java program it’s getting executed but it’s not able to generate a log file please help me

public static void allBatch()
    {
        
         try {
                // Process p =  Runtime.getRuntime().exec("cmd /c stopTomact.bat", null, new File("C:UsersAjayDocuments"));
                 Process process =Runtime.getRuntime().exec("cmd /C start C:UsersAjayDocumentsbatchFile.bat");
                   System.out.println("Stopped"); 
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
        
        
    }

@echo off

@echo off

call :main >myLog.txt 2>&1

:main
if exist "C:UsersAjayDocumentsold TomcatController*.*" (

xcopy /e "C:UsersAjayDocumentsold TomcatController*.*" "C:UsersAjayDocumentsnewTomcatController*" /y
echo %date%—–Copy Successful——%time%

echo —————————————————
net stop Tomcat8
sc query Tomcat8
echo %date%—–Stop Successful——%time%

rem start notepad "C:UsersAjayDocuments"

)else echo %date%——- sorry Failed TO Copy —–%time%

timeout 5 > nul
exit

Source: Windows Questions

LEAVE A COMMENT