Batch file only works in certain directory


  1. Posts : 27
    Windows 7 Ultimate x64
       #1

    Batch file only works in certain directory


    I made a batch file that says this:

    Code:
    @echo off
    cd C:\Users\John\Desktop
    rename ring.gif ring.jpeg
    The actual batch file is saved on my I:\ drive, not my C:\ drive. My I:\ drive is an internal HDD that is able to talk with my C:\ drive. When I execute the .bat file, it does nothing besides quickly opening the command prompt and then closing it. When I take the .bat file and put it on my desktop and run it, it works as it should (ring.gif gets renamed to ring.jpeg). Why doesn't it work when it is on my I:\ drive?
      My Computer


  2. Posts : 5,642
    Windows 10 Pro (x64)
       #2

    You need to add the "/D" switch to cd that might help. "cd /D C:\Path..."
      My Computer


  3. Posts : 27
    Windows 7 Ultimate x64
    Thread Starter
       #3

    It worked like a charm. Thank you very much!
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 16:21.
Find Us