DOSKEY to change path and run a command

2k views Asked by At

So I have two things I need to do, and it seems DOSKEY is the way to go but i am new to it. What I am trying to do is from the C prompt is change drives to D, then go into a folder called run_folder then execute a command that its redirect into a log file. So it would look like this.

C:\Users> D:
D:\> cd run_folder
D:\run_folder> run_command.exe > d:\run_folder\logs_current_date_time.txt 

I am trying to convert so that all i have to type is run_CA from the C prompt.. Any ideas? how i can accomplish this using DOSKEY

2

There are 2 answers

3
FrankPl On BEST ANSWER

Put the three lines of code into a file named run_CA.cmd. Then you can type run_CA to execute it. No need for DOSKEY.

0
Dave Bower On

Ok, so I'm 3 years late to this party but for others who might want to know you can use $T to split commands:

doskey run_CA=D: $T cd run_folder $T run_command.exe ^> d:\run_folder\logs_current_date_time.txt

Note the caret is required on the command line to escape the redirection, otherwise you'll redirect the output from doskey!