How do I create a command on Windows without having to create a file?

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.

You can create an Environment variable, and then call it using %hello%

![![enter image description here

![enter image description here

![enter image description here

enter image description here

enter image description here