1

I have several simple batch routines I run daily on Windows 10 [Home & Pro], and while the routines run fine, after the routine runs in a terminal, the black terminal window remains open:

@echo off
setlocal
set mm=%Date:~0,2%
set dd=%Date:~3,2%
set yy=%Date:~6,2%
set hh=%time:~0,2%
set mn=%time:~3,2%

REM ROUTINE UPDATED 06-06-17 ADDED INDIVIDUAL FOLDER TRANSFERS AND 1970 FILES MOVED SEPERATELY

TITLE WS01 BC TO CCSO04 120D   %yy%%mm%%dd% %hh%%mn%
COLOR CE

MD "C:\DATA FILES\WS01 PHOTOS\Archive Backup\Logs\DAILY WS01 FILES\%yy%%mm%%dd%"

Robocopy "\\WS01\BCTEMP\506" "\\ccso04\CAM_120\506" /E /S /V /TEE /NP /XN /XO /XC /MOVE /FFT /R:2 /W:1 /XF *.BAT /XF *.LNK /XD "#recycle" /XD "~TRANSFER_LOGS" /XF "*1970*" /XD "*1970*" /ETA /A-:SHR /LOG:"C:\DATA FILES\WS01 PHOTOS\Archive Backup\Logs\DAILY WS01 FILES\%yy%%mm%%dd%\%yy%%mm%%dd% %hh%%mn% WS01 CAM 506 TO 120D.TXT"
MD "\\WS01\BCTEMP\506"

Robocopy "\\WS01\BCTEMP\513" "\\ccso04\CAM_120\513" /E /S /V /TEE /NP /XN /XO /XC /MOVE /FFT /R:2 /W:1 /XF *.BAT /XF *.LNK /XD "#recycle" /XD "~TRANSFER_LOGS" /XF "*1970*" /XD "*1970*" /ETA /A-:SHR /LOG:"C:\DATA FILES\WS01 PHOTOS\Archive Backup\Logs\DAILY WS01 FILES\%yy%%mm%%dd%\%yy%%mm%%dd% %hh%%mn% WS01 CAM 513 TO 120D.TXT"
MD "\\WS01\BCTEMP\513"

Robocopy "\\WS01\BCTEMP\514" "\\ccso04\CAM_120\514" /E /S /V /TEE /NP /XN /XO /XC /MOVE /FFT /R:2 /W:1 /XF *.BAT /XF *.LNK /XD "#recycle" /XD "~TRANSFER_LOGS" /XF "*1970*" /XD "*1970*" /ETA /A-:SHR /LOG:"C:\DATA FILES\WS01 PHOTOS\Archive Backup\Logs\DAILY WS01 FILES\%yy%%mm%%dd%\%yy%%mm%%dd% %hh%%mn% WS01 CAM 514 TO 120D.TXT"
MD "\\WS01\BCTEMP\514"

Robocopy "\\WS01\BCTEMP\515" "\\ccso04\CAM_120\515" /E /S /V /TEE /NP /XN /XO /XC /MOVE /FFT /R:2 /W:1 /XF *.BAT /XF *.LNK /XD "#recycle" /XD "~TRANSFER_LOGS" /XF "*1970*" /XD "*1970*" /ETA /A-:SHR /LOG:"C:\DATA FILES\WS01 PHOTOS\Archive Backup\Logs\DAILY WS01 FILES\%yy%%mm%%dd%\%yy%%mm%%dd% %hh%%mn% WS01 CAM 515 TO 120D.TXT"
MD "\\WS01\BCTEMP\515"

Robocopy "\\WS01\BCTEMP\516" "\\ccso04\CAM_120\516" /E /S /V /TEE /NP /XN /XO /XC /MOVE /FFT /R:2 /W:1 /XF *.BAT /XF *.LNK /XD "#recycle" /XD "~TRANSFER_LOGS" /XF "*1970*" /XD "*1970*" /ETA /A-:SHR /LOG:"C:\DATA FILES\WS01 PHOTOS\Archive Backup\Logs\DAILY WS01 FILES\%yy%%mm%%dd%\%yy%%mm%%dd% %hh%%mn% WS01 CAM 516 TO 120D.TXT"
MD "\\WS01\BCTEMP\516"

REM -- LAST LINE TO COPY 1970 FILES AND FOLDERS
MD "\\CCSO04\CAM_120\%yy%%mm%%dd% %hh%%mn% TRANSFERS"
Robocopy "\\WS01\WS01_bctemp" "\\ccso04\CAM_120\%yy%%mm%%dd% %hh%%mn% TRANSFERS" /E /S /V /TEE /NP /XN /XO /XC /MOVE /FFT /R:2 /W:1 /XF *.BAT /XF *.LNK /XD "#recycle" /XD "~TRANSFER_LOGS" /ETA /A-:SHR /LOG:"C:\DATA FILES\WS01 PHOTOS\Archive Backup\Logs\DAILY WS01 FILES\%yy%%mm%%dd%\%yy%%mm%%dd% %hh%%mn% WS01 CAM 1970 FILES TO 120D.TXT"

RD "\\CCSO04\CAM_120\%yy%%mm%%dd% %hh%%mn% TRANSFERS"

MD "\\WS01\BCTEMP\506"
MD "\\WS01\BCTEMP\513"
MD "\\WS01\BCTEMP\514"
MD "\\WS01\BCTEMP\515"
MD "\\WS01\BCTEMP\516"

CALL "C:\Data Files\WS01 Photos\Archive Backup\TREE - WS01.BAT"
CHOICE /D Y /M "TRANSFER COMPLETE - READY TO CONTINUE" /T 30
EXIT

The majority of my routines are not calling any other batch routines within them, although I do have two that start a second batch file routine after the first runs using call, and previously ran correctly on the first releases of Windows 10.

  • If I run one of the routines on my laptop [Windows 10 b16299.371], the command window closes correctly
  • I have noticed if I open a command window from the start/run menu on one of the 'problem machines (also running b16299.371), and type exit the window does close

I've tried:

  • setting the terminal window default settings to disable "QuickEdit"
  • running the cmd window in Windows 10 default mode, Legacy mode, and as Administrator
  • running a VBS script to send at the end:
    • Alt+F4, but discovered even if I physically press Alt+F4 while one of the terminal windows is open, it does not close the window (you have to press the red X on the window to get it to close)
    • Alt+Space+C, and while this works if I physically press the keys, the executed VBS script does not
  • searching for "Windows 10 command window hangs" and "does not close", with none of the answers addressing hwo to get the terminal window to close after running commands using a batch file
  • ending routines without any exit commands, as well as with exit and Exit /b 0 on the very last line

Since I have these routines running on one of my client's computers every morning before they come into work, I have instructed him to click the X on the command window if it is still open when they get to the office, but would love to find out:

  • Why is the Windows 10 command terminal window doing this?
    (knowing why this is occurring is as important to me as getting a solution)
  • How do I get these windows to close after running through the batch routine?

4
  • Do the transfers complete, so just the blank cmd screen is showing?
    – Cory M
    May 8, 2018 at 18:38
  • Yes, the routines do complete fine. Sorry I've been offline for the past few days. May 15, 2018 at 2:41
  • When the Choice line runs, it allows you to enter an answer, or it times out, but then there is just a blank line... Same even if I press CTRL+C, it asks to cancel the batch file, and no matter what you press, it just goes to a blank line and stops. May 15, 2018 at 2:48
  • Any other suggestions on this... I know that I can't be the only one that is having command prompts just hanging out on the screen... May 20, 2018 at 22:44

1 Answer 1

0

How about adding a taskkill to cmd?

@echo off 
c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM cmd.exe

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .