Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

How can I execute a command inside a command on command prompt

Options
  • 17-03-2006 12:15am
    #1
    Closed Accounts Posts: 201 ✭✭


    Is there a way to execute a command inside a command on command prompt in windows

    specifically i will have a path written to a file and I would like be able to execute a cd command to open that path something like

    cd type path.txt

    where the type path.txt command executes first and then cd runs on that


Comments

  • Registered Users Posts: 2,497 ✭✭✭optiplexgx270


    batch file? otherwise piping


  • Closed Accounts Posts: 201 ✭✭bazcaz


    cd | type path.txt

    just prints the contents of the file way am I doing wrong??


  • Registered Users Posts: 2,497 ✭✭✭optiplexgx270


    thats the wrong way round for a start u could use a batch file


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,692 Mod ✭✭✭✭Capt'n Midnight


    To list all the files in the windows dir with an E in their name

    dir > dir.txt & find /i "e" dir.txt > e.txt & notepad e.txt


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    What are you trying to do exactly? Are you trying to store that path so you can go back there at a later date?

    If so do something like this..
    :We are at start directory
    pushd workdir
    
    :We are in the workdirectory and have stored the start directory.
    :** Do work here..
    
    :popd
    
    :We are now back in the start directory. 
    

    If you must go with a file method then this should work..
    :create the path.txt file. 
    cd > path.txt 
    
    :This will change directory to the path listed in the file.
    FOR /F "tokens=1" %v IN (path.txt) DO cd %v
    


  • Advertisement
Advertisement