Windows 7 Forums


Reply
Thread Tools

[SOLVED] Add functions to command prompt.

 
 
Fire cat Fire cat is offline
Established Member
Join Date: Mar 2010
Posts: 1,156
Thanked: 164
 
      11-23-2010
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
 
Reply With Quote
 
 
 
 
Fire cat Fire cat is offline
Established Member
Join Date: Mar 2010
Posts: 1,156
Thanked: 164
 
      11-23-2010
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
 
Reply With Quote
 
clifford_cooley clifford_cooley is offline
(c_c)
clifford_cooley's Avatar
Join Date: Mar 2009
Location: Arkansas, USA
Posts: 4,500
Thanked: 929
 
      11-23-2010
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.
 
Reply With Quote
 
Fire cat Fire cat is offline
Established Member
Join Date: Mar 2010
Posts: 1,156
Thanked: 164
 
      11-23-2010
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:
Quote:
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:
Quote:
@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
 
Reply With Quote
 
Bugsy Bugsy is offline
Established Member
Bugsy's Avatar
Join Date: Nov 2010
Location: Glasgow UK
Posts: 241
Thanked: 28
 
      11-23-2010
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.

Pointless I know!
 
Reply With Quote
 
Fire cat Fire cat is offline
Established Member
Join Date: Mar 2010
Posts: 1,156
Thanked: 164
 
      11-23-2010
Quote:
Originally Posted by Bugsy View Post
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.

Pointless I know!
Yes, pointless

I know that, by the way. color 2 gives it a nice sci-fi look xD
 
Reply With Quote
 
Bugsy Bugsy is offline
Established Member
Bugsy's Avatar
Join Date: Nov 2010
Location: Glasgow UK
Posts: 241
Thanked: 28
 
      11-23-2010
I would offer some useful info but to be honest i dont deal in scripts unless its simple stuff
 
Reply With Quote
 
TrainableMan TrainableMan is online now
^ The World's First ^
TrainableMan's Avatar
Join Date: May 2010
Location: PA, USA
Posts: 4,621
Thanked: 881
 
      11-24-2010
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.
 
Reply With Quote
 
clifford_cooley clifford_cooley is offline
(c_c)
clifford_cooley's Avatar
Join Date: Mar 2009
Location: Arkansas, USA
Posts: 4,500
Thanked: 929
 
      11-24-2010
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.
 
Reply With Quote
 
Fire cat Fire cat is offline
Established Member
Join Date: Mar 2010
Posts: 1,156
Thanked: 164
 
      11-24-2010
Quote:
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Driver for Canon ip1500 printer? Tathra Drivers 34 03-05-2012 07:52 PM


All times are GMT +1. The time now is 03:24 PM.
W7Forums is an independent website and is not affiliated with Microsoft Corporation.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33