Reputation: 262
I want to modify existing cmd commands, both to change out the code to another batch file and to modify the code.
For example, when I type "calc" it opens the calculator app but I want it to open a batch script I made, and when I want to edit the "help" screen. How can I modify the code that runs when I type in existing cmd commands such as tree, help and calc?
Upvotes: 0
Views: 1335
Reputation: 51
You may not be able to replace or modify all exiting programs and/or scripts, but you can "trick" your Windows to prioritize / execute yours that are similarly named.
When you type "calc" in the command prompt, you will effectively execute the file:
C:\Windows\System32\calc.exe
You need to look at the Environmental Variable named "Path"; this is where you identify which directories should be seen by your system as "global". Any EXE, BAT or CMD you'll try to execute will look at the current directory first; and if it isn't found it will try to find it in the directories listed in "Path".
For example. Lets say you want to run your own file called help.exe; a console app that you created.
You should see the following screen:
Here's a tiny program I wrote. I compiled it as help.exe, and copied it to the directory that I added as a Path (C:\CustomBatchFiles):
class Help
{
static void Main(string[] args)
{
Console.WriteLine("Start executing your program / script from here.");
}
}
It will produce the following output:
Upvotes: 1