SOLVED Add functions to command prompt.


Fire cat

Established Member
VIP Member
Joined
Mar 7, 2010
Messages
1,157
Reaction score
191
Heya Guys!

So, as the title indicates, I want to add functions to my command prompt. But how? Could I make a DLL for this? If so, (I think it is possible with a DLL) how would I code it?

For the guys that are wondering why, it's simple. I develop websites a LOT. So there are some tasks that are repetetive - and are just plain boring.

I know some members here have some coding experience, so that's why I'm asking.
Thanks :)
 
Ad

Advertisements

Fire cat

Established Member
VIP Member
Joined
Mar 7, 2010
Messages
1,157
Reaction score
191
Right. I got it mostly figured out on my own xD

To add functions to the command prompt, you just need to place a file containing the code to execute inside the system32 folder of your Windows install.

Now, I just need to find a way to make parameters for batch files :D
 

clifford_cooley

VIP Member
Joined
Mar 8, 2009
Messages
5,063
Reaction score
1,184
Put your repetitive code in a script file then each time you want to run the code, you would run the script.

How exactly are you coding?
Are you using loops and goto features?

Another way to minimize repetitive coding is to place the repetitive code within a sub. then you would call upon the sub when you want to run the code within.
 

Fire cat

Established Member
VIP Member
Joined
Mar 7, 2010
Messages
1,157
Reaction score
191
I was thinking of using a C++ DLL to start with, but I found a simpler way.
I'm now using a file called func.bat in my system32 folder.

If I want to run a command from my code, I just type:
func test
My batch file then looks for a match in the available functions, and if it is, it "goto's" to it.

Here's the code I came up with to try it out:
@echo off
if "%1"=="test" goto test

:home
echo Invalid command!
pause>nul
cls

:test
echo Testing this script.
It doesn't do anything else than print "Testing this script" for the moment, but at least I know how to do this now ;)
 
Joined
Nov 6, 2010
Messages
241
Reaction score
33
You can change the colours if you wanted?

For example if you write; color 1
it will change the white font colour to blue.

After trying all the colour codes you can get the one you like. But this is not enough, you can change the background color too.

For this, you need to right click the title bar of the Command Prompt. From here you need to select its properties.

From the properties windows that will be opened, you need to select the colours tab.

You will see the Screen Background, Select the desired background colour. :D

Pointless I know!
 

Fire cat

Established Member
VIP Member
Joined
Mar 7, 2010
Messages
1,157
Reaction score
191
You can change the colours if you wanted?

For example if you write; color 1
it will change the white font colour to blue.

After trying all the colour codes you can get the one you like. But this is not enough, you can change the background color too.

For this, you need to right click the title bar of the Command Prompt. From here you need to select its properties.

From the properties windows that will be opened, you need to select the colours tab.

You will see the Screen Background, Select the desired background colour. :D

Pointless I know!
Yes, pointless :D

I know that, by the way. color 2 gives it a nice sci-fi look xD
 
Ad

Advertisements

Joined
Nov 6, 2010
Messages
241
Reaction score
33
I would offer some useful info but to be honest i dont deal in scripts unless its simple stuff :eek::D
 

TrainableMan

^ The World's First ^
Moderator
Joined
May 10, 2010
Messages
9,342
Reaction score
1,586
It's called a BAT file kiddies. The ability to write a BAT file came long before Scripts and long before FireCat even existed!

Generally you just create individual BAT files rather than have one file and pass it the function desired as a parameter (just make sure the BAT file name isn't already a DOS command). So instead of "func test" or "func printit" you would just name it test.bat, printit.bat etc.
 

clifford_cooley

VIP Member
Joined
Mar 8, 2009
Messages
5,063
Reaction score
1,184
XP and up added new functionality thats not compatible with pre-XP OS's so the file extension was renamed from BAT to CMD. You can rename any *.BAT file to *.CMD and execute the file the same way. They did this to keep from accidentally executing a script designed for XP on a pre-XP machine. All of my script files now have the CMD extention.
 
Ad

Advertisements

Fire cat

Established Member
VIP Member
Joined
Mar 7, 2010
Messages
1,157
Reaction score
191
Generally you just create individual BAT files rather than have one file and pass it the function desired as a parameter (just make sure the BAT file name isn't already a DOS command). So instead of "func test" or "func printit" you would just name it test.bat, printit.bat etc.
I know. But I was just testing passing parameters to the batch file. I don't want to type "func" each time I want to do something, and have to edit an enormous bat file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top