DOS Tips & Tricks

Industrial Code and Solutions

for Getting Things Done

_____________________________

Blog List FileMaker® Scripting Mac OS X | Tech Help Home | Windows

DOSKEY    





Loading Doskey macros automatically

There is a problem after you have closed a Windows DOS command window: doskey is also removed, and you have to type it again every time you run cmd.

The solution is to modify the cmd shortcut in the start menu.  Now everytime the cmd is loaded doskey is loaded also, with optional macros or even a whole macrofile.  This example assumes that your doskey macros are stored in a file named "macrofile.txt" in the macros folder just off the root of the C drive.  Modify your path according to your situation.

Modify the cmd shortcut target from

%SystemRoot%\system32\cmd.exe

to

%SystemRoot%\system32\cmd.exe /k doskey /macrofile=c:\macros\macrofile.txt



( The /k switch keeps the command window open after doskey is executed. )

 - OR -
Here is an alternate method if you are comfortable making registry edits:
Change the value of the registry key:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor to

Value name: AutoRun
Value data: doskey /macrofile=c:/macros/macrofile.txt

Changing the registry key gives a benefit, or removes a pitfall, depending on how you look at it; if you add code to the shortcut properties the code completion for the command prompt won't work any more.

Here's how to get your doskey macros in a text file:

  1. Run the dos command doskey /macros:all > C:\macros\macrofile.txt

That's all there is to it.   Whenever you add new doskey macros, just run this command again.

Here is the contents of my macrofile.txt: 

[cmd.exe]
    ls=dir $*
    bye=exit
    emacrofile=edit C:\macros\macrofile.txt
    e=edit $*
    dt=cd %userprofile%\desktop
    desktop=cd %userprofile%\Desktop

[ftp.exe]
    b=binary

Feel free to copy and paste into your own macro file if you like them.

Here's what they do:

  • ls=dir $*  makes ls the same as dir.  The $* passes along any arguments you include.
  • bye=exit  makes bye the same as exit.
  • And so on...