몇 가지 명령을 호출하고 궁극적으로 powershell 스크립트를 실행하는 배치 파일이 있습니다. 그것은 수동으로 잘 실행되지만, 작업 스케줄러에서는 일부 작업을 완료하지만 실제로 powershell 스크립트 (마지막 명령은 bat 파일에서 실행되지 않음)를 볼 수 있습니다. 스크립트는 전송되는 java 파일에 의해 작성되거나 덮어 쓰여집니다 아웃 이메일. 모든 것이 업데이트되고 필요하지만 궁극적으로 전자 메일은 전송되지 않습니다. Win 탐색기에서 박쥐 파일을 클릭하면 예상대로 작동합니다.Bat 파일이 수동으로 실행되고 작업 스케줄러로 완료되지 않음
@echo off
set Pathname="C:\Users\administrator\Documents\EmailNotification\EmailNotificationJava"
cd %Pathname%
REM ECHO Directory: C:\Users\administrator\Documents\Notification
CALL IndividualCMDCommands.bat
set Pathname="C:\Users\administrator\Documents\EmailNotification\EmailNotificationJava\src"
cd %Pathname%
XCOPY C:\Users\administrator\Documents\EmailNotification\EmailNotificationJava\*.txt C:\Users\administrator\Documents\EmailNotification\EmailNotificationJava\src /Y
javac -cp .;C:\Users\administrator\Documents\EmailNotification\EmailNotificationJava\joda-time-2.9.3\joda-time-2.9.3.jar ParseInfo.java
java -cp .;C:\Users\administrator\Documents\EmailNotification\EmailNotificationJava\joda-time-2.9.3\joda-time-2.9.3.jar ParseInfo
ECHO ParseInfo
REM set Pathname="C:\Users\administrator\Documents\Notification"
REM cd %Pathname%
ECHO Powershell
REM SET ThisScriptsDirectory="C:\Users\administrator\Documents\EmailNotification\EmailNotificationJava\src"
SET PowerShellScriptPath=%TC:\Users\administrator\Documents\EmailNotification\EmailNotificationJava\PSCMD.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";
ECHO Complete
배치 파일을 사용하는 이유는 무엇입니까? 전체 스크립트에 PowerShell을 사용하기 만하면됩니다. –
이 스크립트를 실행할 때마다 PowerShell 스크립트를 덮어 씁니다. PowerShell 스크립트를 사용하는 이유는 전자 메일 명령을 별도의 파일에 보관하여 필요할 경우 변경할 수 있기 때문입니다. 그래서 저는 그 부분을 자체 파일에 보관하고 싶습니다. –
배치 파일이 필요하지 않은 대체 접근 방식을 권장합니다. –