Search code examples
windowsbatch-filecmd

How to execute cmd command from text file?


As title says, I need to execute cmd command from text file.Let's say I have text file called file and in it it's written Color A.I need something like command: type file.txt and not just write it on screen, but I want it to press enter meanwhile.Batch file options are welcomed too.Thank you.


Solution

  • You can use save your normal file with batch programming in it with .bat extension. And run that file WhateverNameItIs.bat on your command prompt.

    Saved it as file.bat

     @ECHO ON
     ECHO Color A
    

    In your case you can drag file from your where your are to command prompt. Or Using CD you can reach out where your file is saved within your command prompt. Fire up file.bat on your command prompt will execute whatever batch programming is written on that file.