One of the features available under UNIX is the Message of the Day (MOTD). This is run every time you start a command prompt and displays the content of a file. In addition, the UNIX shells allow all sorts of stuff to be run and configured every time you start a new prompt using the .profile and .bashrc command files.
Windows users don’t generally expect that kind of flexibility from their command prompts. However, Windows does indeed support the use of an
autorun into which you can shoe-horn any command you like.
So for my standard setup, I make the shell autorun run a
.profile.cmd file that sits in the
%USERPROFILE% folder. From that file, I can run anything I like.
To set up a shell autorun, you have to edit the registry so the usual warnings to be careful and back things up apply.
There are two locations you can set, one for the machine as a whole and one for the logged-in user.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor
If you want to set an autorun for another user, you need to go down
HKEY_USERS and find the appropriate one. It is really easier just to log in!
In one or both of those locations, add a new “String Value” (
AutoRun with the value:
Now create that file and put in a message such as:
@echo "Hello and welcome to my command prompt"
Save the file and open a new shell and you should see the message just after the Microsoft copyright.
This should work on all versions of Windows at least from XP onwards.
If you want to add this to a batch file to set up new machines, here is the command you need:
reg.exe ADD "HKLM\SOFTWARE\Microsoft\Command Processor" /v AutoRun /t REG_SZ /d ^%USERPROFILE^%\.profile.cmd /f
(Note that the above needs to go on a single line)
- 2018-04-22 - Tidy formatting, reformat for Hugo output.