Windows – How to create a command on Windows without having to create a file

batch filecommand lineechowindows 10

I want to create the command hello without having to create a file like hello.bat.
I want the command without the file.
The command must execute an echo Hello World!.

Is there a way to do it on Windows?

Best Answer

I want to create the command hello without having to create a file

You can use doskey.

  1. Open a cmd shell

  2. Enter the following command:

    doskey hello=echo Hello world!
    
  3. Run the command:

    hello
    

Example:

F:\test>doskey hello=echo Hello world!

F:\test>hello
Hello world!

F:\test>

Further Reading

  • doskey - Recall and edit commands at the DOS prompt, and create macros. You cannot run a Doskey macro from a batch file.
Related Question