Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 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, Registered Users 2 Posts: 2,587 ✭✭✭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, Registered Users 2 Posts: 2,587 ✭✭✭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: 96,006 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, Registered Users 2 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