DOSKey

This is not a C/C++ question, but I would appreciate the answer because it has to do with the way I compile my code.

I recently reinstalled Windows XP SP3, and am unable to get back to the way I used to compile before reinstallation. The way I had set it up before, was that to compile, all I had to do was type gcc or g++ and then any files or options I wanted to pass to it. ( I use MinGW, because I learned C on a Linux platform, and am accustomed to the format. )

I am fairly certain that I used the command DOSKEY to do this, but I can't get quite the same results this time around. The problem I have is saving the macro. Before, it was as if gcc and g++ were built-in commands, but now, the closest I can get is saving these macros to a file and having to reload that file with the doskey command before I use them, which is essentially useless. By the time I do all that typing, I may as well have typed in the original, full path to gcc.exe.
Last edited on
Crud, I was just about to install SP 3. I hope this doesn't actually booger DOSKey...

I've got all my command prompt shortcuts to open a window in a specific position with a specific font and to execute a little setup script in my D:\bin directory (something akin to .profile or .bashrc or .cshrc or whatever your shell took).

prompt.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off
set path=d:\bin;%PATH%
set dircmd=/ogn
set LS_OPTIONS=-bhACp --streams
doskey >nul
doskey cp=copy $*
doskey lesss=less -S $*
doskey deltree=rd /s/q $*
doskey vi=notepad $*
doskey dird=dir /ad /d $*
doskey python=C:\PROGRA~1\Python25\python.exe $*
doskey pythonw=C:\PROGRA~1\Python25\pythonw.exe $*
title Prompt
echo on


It doesn't look like much, but it does all the essential things: it initializes my path so that all my utils are first in line and sets up all the aliases (doskey macros --for others reading).

In my D:\bin directory I've got little scripts to automatically initialize the programming environment on first use. For example:

g++.bat
1
2
@mpath a 0 C:\PROGRA~1\MinGW\bin
@"g++" %*

(The mpath.exe is a program I wrote for manipulating the command path on the command line. Currently my site is down but if you want a copy I'll be glad to send you one.)

In this case, the mpath command is equivalent to @set PATH=C:\PROGRA~1\MinGW\bin;%PATH%

So, the first time I type "g++ something something something..." it finds my batch script, initializes the environment, and executes g++ as I would assume it would be executed. Thereafter, MinGW's bin directory is listed before my bin directory, and g++ gets executed directly.

:-)

Now if you'll excuse me, I've got to get back to Avatar Aang...
Last edited on
Well if you have something that I could use on my command line so that typing 'gcc' calls my compiler, that would be pretty cool, but I'm positive I didn't do nearly that much work last time.

Are there any other ways to create macros that command prompt will remember?
?

Use doskey. It is the only way to create a command-line macro in the DOS shell emulator.

The use of a startup script is a pretty standard thing to do. Just make sure the shortcut you use to start the command shell looks something like:

%windir%\system32\cmd.exe /k d:\bin\prompt.bat
Oh sweet! Thanks
Topic archived. No new replies allowed.