Site Overlay

Customized Windows command prompt

I personally use the command prompt on Windows a lot, but it's always been very boring to look at. Now I know there are command prompt replacer apps out there which make it look much better (like Cmder), but I wanted to see how far we can customize it without installing any extra software. So let's see how far we can go.

Startup script

The first step is to create a batch script which will be run when we start the console, and a shortcut in the start menu or taskbar to launch it. Creating a batch script is easy, just create a file called _startup.bat and put it in your user folder. You can add a welcome message to it if you like:

echo Welcome to my terminal!


Next comes creating the shortcut. To create a shortcut, we can right-click a blank spot in our user folder, and select New > Shortcut. In the location field we can enter this:

cmd /K "C:\Users\<username>\_startup.bat"

The /K flag will run our script and return us to the command prompt. Now when we start the terminal, we should see our welcome message at the top.

our custom terminal, still looking pretty ugly

We can also customize the icon of the shortcut, by right-clicking it and going to Properties > Change Icon. In the icon select dialog we only have the icon exported by cmd.exe, but we can choose from a list of icons in shell32.dll by putting some randon text into the file select field and pressing Enter. This will throw an error, but will then default back to shell32.dll.

shortcut icon selection

Next we can add some colors to the terminal. Right-click the shortcut and select Properties > Colors tab. You can change any options on these tabs, but I've just changed opacity to 95%, and Screen Text to (red = 12, green = 180, blue = 12).

starting to look better

Another recent option on Windows 10 is under the Terminal tab, to disable scroll-forward. This removes all the blank space and the scrollbar on the right, which is quite cool.

Now we can drag this shortcut wherever we want, we can pin it to the start menu, or the taskbar, etc. Nice!

Better startup script

We now have a custom icon, custom color and a custom start script. We can enter any combination of commands into this startup script to customize it the way we want. Here's what I've got in mine, if you want to use it, you can copy this script into your _startup.bat file.

rem Setup path to point to desktop
cd "%USERPROFILE%\Desktop"

rem Prepare script
setlocal enabledelayedexpansion
echo off
echo Please wait...
title Please wait...

rem Get user's display name
SET cmd="net user %USERNAME% | FIND /I "Full Name""
FOR /F "tokens=3 delims=, " %%A IN ('%cmd%') DO SET UserDisplayName=%%A

rem Get installed RAM
SET cmd="wmic ComputerSystem get TotalPhysicalMemory | findstr [0-9]"
FOR /F %%A IN ('%cmd%') DO SET TotalMemory=%%A
set TotalMemory=%TotalMemory:~0,-3%
set /a TotalMemory=%TotalMemory%/1024
if %TotalMemory% gtr 2048 (
  set /a TotalMemory=!TotalMemory!/1024
  set TotalMemory=!TotalMemory! GB
) else (
  set TotalMemory=!TotalMemory! MB

rem Get system name
SET cmd="wmic ComputerSystem get name"
FOR /F "skip=1" %%A IN ('%cmd%') DO (
  set ComputerName=%%A
  goto leaveSystemName

rem Welcome message
title %UserDisplayName%'s Terminal
echo Welcome to %UserDisplayName%'s terminal :)
echo System details:
echo - System name: %ComputerName%
echo - Username: %USERNAME%
echo - Installed RAM: %TotalMemory%

rem Usage per drive
SET cmd="wmic LogicalDisk get DeviceID,FreeSpace,Name | findstr .:"
for /F "tokens=1,2" %%a IN ('%cmd%') DO (

  rem Calculate free space in MB/GB
  set Space=%%b
  set Space=!Space:~0,-6!
  if not "!Space!" == "" (
    set /a Space=!Space! / 1024
    set Space=!Space! GB

    rem Output
    echo - Free space on drive %%a !Space!



Wow, what a mess. Windows batch scripts really are pretty terrible. Let's analyze a few lines here though…

1-3: Sets the current working directory to your desktop.
5-10: Sets the window title, prevents command params being echoed out, and allows us to use delayed expansion, which allows us to overcome the way batch scripts handle variables inside of blocks. It allows us to use the !VarName! style instead of %VarName%, which is expanded during the line execution instead of just at the start of the block.
12-14: Gets the user's display name into the UserDisplayName var.
16-26: Gets amount of installed RAM and puts it in the TotalMemory var.
28-34: Puts the system name into the ComputerName var.
36-44: Clears the screen and starts displaying the welcome message.
46-63: Displays free space for each drive.

done! and looking pretty good.

And that's it! Since it's running a batch script, you can also execute any command line application and use the output in your welcome message.