JSI Tip 6838. How do I create a command alias?

I hate typing, specially when using my laptop, so I like to create shortened versions of frequently used commands.

In tip 1133, I created a Run alias.

To create a command alias, simply create a batch file that shortens the typing, and if you wish, includes command options that you always use.

As an example, I created Use.bat to perform the net use function.

The syntax for using Use.bat is:

use <Drive:> \\<ServerName>\<ShareName> \[</switches>\]

While this syntax only saves me 4 keystrokes, I have taken the opportunity to make the display friendlier.


use K: \\JSI001\NETLOGON /Persistent:Yes

The console display is:

Connecting as K: \\jsi001\netlogon /persistent:Yes... \[ok\]

use K: /d

The console display is:

Connecting as K: /d... \[ok\]

Use.bat contains:

@echo off
(Set /P _=Connecting as %*... ) <NUL ^& Net Use %* >NUL 2>&1 && Echo \[ok\] || Echo \[error\]

Other possibilities

If you don't want to change the display, Use.bat would contain:

@echo off
net use %*

NOTE: See Conditional Processing Symbols, Filters, and Redirection for batch processing.

NOTE: See A better pipe command, but this time I piped to NUL.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.