Called Command window doesn't close in batch & powershell hybrid -


edit people focusing on program being called, issue occurs on xcopy batches 1 below.

c:  /f "tokens=1-4 delims=/ " $$a in ('date /t') (set weekday=%%a& set day=%%b& set month=%%c& set year=%%d)  set jdate=%day%-%month%-%year%  g:  md brd_backup_%jdate%  cd brd_backup_%jdate% md data md programs  f:  cd\brdata  xcopy d:\brdata\data*.* g:\brd_backup_%jdate%\brdata\data*.* /a /y /s  xcopy d:\brdata\programs*.*  

original post below:

i replaced server new server 2012 r2 box. batch below supposed prompt store number import file software. worked fine 6 years on old server. copied batch file new server , batch file not close cmd window when done. happens batch construct, old ones or brand new ones. have read should begin batch start "" , enclose batch in quotes, did not work (i may have done wrong). how cmd windows close automatically? why did stop? answer below says powershell may have no experience powershell , cannot work.

@echo off  set store= 01  set /p store= store import? (two digits):    f:  cd\brdftp    ::  ::     pulls store  :::::::::::::::::::::::    cd\brdftp\store%store%      xcopy ir*.* f:\brdata  xcopy *.pdf /a /s /y f:\brdata\images\dsdefimg  del *.* /q      ::                          imports files brdata  :::::::::::::::::::::::::::::::::::::::::::::::::::::::  f:  cd\brdata    start /w plbwin rftw9417 -auto

modify original script run:

start "" /b plbwin rftw9417 -auto 

alternatively, try:

call plbwin rftw9417 -auto 

if batch window still doesn't close, replace fullpath path plbwin.exe, run powershell command batch start target program in hidden window:

set "img=fullpath\plbwin.exe" & set "cfg=rftw9417 -auto" powershell -noprofile -executionpolicy bypass -command "& {start-process -windowstyle hidden -filepath '%img%'"^  "-workingdirectory '%img:~0,-11%' -argumentlist '-f ""%cfg%"""'}" 

Comments