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

Author Topic: CHDIR/CD Command no longer works in DOS  (Read 6101 times)

0 Members and 1 Guest are viewing this topic.

Laxalife

    Topic Starter


    Greenhorn

    CHDIR/CD Command no longer works in DOS
    « on: April 15, 2008, 07:48:39 AM »
    Hi,

    I'm working on creating a batch file for my company. I was working on it about 5 months ago, got side tracked and I am working on it again. The batch file is run from the company server, which is running Windows Server 2003 SP2. I Checked the DOS and it says it running WINDOWS Version 5.2.3790. 5 months ago, all DOS commands worked on the server, but now the server doesn't seem to want to recognize the CHDIR or CD DOS command. See below for example:

    My problem is that the batch file is located on the D drive. So when I start the command it starts me off on C:\Documents and Setting\<user profile>. When I type in CHDIR or CD and D:\location it does not give me an error. But in the next line, when its waiting for another command....it still lists me as being in C:\Documents and Settings\<user profile>.

    I double checked to see if I was maybe on the D drive, so I typed DIR....but it did not show any files from the D drive. I also tried calling my batch file, but it says it did not recognize the command. Which means, to me, that I'm still on the C drive.

    Please help.

    gpl



      Apprentice
    • Thanked: 27
      Re: CHDIR/CD Command no longer works in DOS
      « Reply #1 on: April 15, 2008, 08:26:10 AM »
      You need to change to the server drive & directory

      D:

      would change the drive, but CD /D d:/path allows you to change the drive as well as the directory at the same time.

      If you wanted to change to the directory where your batch was, add this to near the start
      CD /D  "%~dp0"

      This takes the full name of the batch (%0) and strips out the drive and directory from it .... the quotes are there in case there are spaces in the folder name

      Good luck
      Graham

      Laxalife

        Topic Starter


        Greenhorn

        Re: CHDIR/CD Command no longer works in DOS
        « Reply #2 on: April 15, 2008, 11:48:55 AM »
        Thanks Graham. That helped me out.