1.

Solve : Running a batch file from with a batch file not working right?

Answer»

I am trying to create a directory based on three variables. Then I use the "civmd.bat" file to create subdirectories under that in a standardized format.

Quote

@ECHO OFF
SET /P uname=Please enter your name:
IF "%uname%"=="" GOTO Error
SET /P uname2=Please enter DEFENDANT's Last name:
SET /P caseno=Please enter USA Case Number:
ECHO Hello %uname%, Welcome to DOS inputs!
MD "D:\%uname%\%uname2% %caseno%"
copy d:\civmd.bat "D:\%uname%\%uname2% %caseno%"
CD "D:\%uname%\%uname2% %caseno%"
call "D:\%uname%\%uname2% %caseno%\civmd.bat"
PAUSE
GOTO End
:Error
ECHO You did not enter your name! Bye bye!!
:End

Everything works as planned except that the civmd.bat file that is being "called" runs in whatever directory I have this input.bat file. Not in the "D:\%uname%\%uname2% %caseno%" directory.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.

Code: [Select]cd /d "D:\%uname%\%uname2% %caseno%"
Or you can change the drive first:

Code: [Select]D:
cd /d "D:\%uname%\%uname2% %caseno%"No, it wasn't. It was on my c:\temp. I took it from your question that would matter, so I moved it and it worked.


Discussion

No Comment Found