Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Running a batch file from with a batch file not working right  (Read 2667 times)

0 Members and 1 Guest are viewing this topic.

lionround

    Topic Starter


    Newbie

    • Experience: Familiar
    • OS: Windows 7
    Running a batch file from with a batch file not working right
    « on: October 30, 2015, 09:55:54 AM »
    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.

    Salmon Trout

    • Guest
    Re: Running a batch file from with a batch file not working right
    « Reply #1 on: October 30, 2015, 01:06:09 PM »
    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%"
    « Last Edit: October 30, 2015, 01:32:54 PM by Salmon Trout »

    lionround

      Topic Starter


      Newbie

      • Experience: Familiar
      • OS: Windows 7
      Re: Running a batch file from with a batch file not working right
      « Reply #2 on: October 30, 2015, 01:45:27 PM »
      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.