Is the input.bat stored in a folder on the D drive? The reason I ask is that a CD command will not work if the new directory is on a different drive form the current folder unless you use the /D switch to change the drive, e.g.
cd /d "D:\%uname%\%uname2% %caseno%"
Or you can change the drive first:
D:
cd /d "D:\%uname%\%uname2% %caseno%"