Biggest Addiction - TEA

My Day starts with a TEA . Without TEA no work :)

Music

I don't know why .. but I love to listen video songs after minimizing the player window . Idiotic but that's how it works for me !

Fly High

Very less people may be knowing this ... but I always fly much high in my thoughts ... A world full of stories , fun and adventure !

School

The best place . The foundation of What you are today . I miss my school very much !!

India

Hope , Respect , Ambition , Values - I love my India :) :)

Thursday, September 18, 2014

Some Useful Command Prompt Tricks



Hi, I have compiled a list of commands and tricks which I learnt on the go while working. I thought it may be useful to others also :) 


1. While working on a command prompt from long time , use key F7 to see visually a list of command history. It's very useful to me to easily navigate to command required by pressing up and down key.






Yes , you can directly use up and down key also to do this, but I feel just going to last few commands it's ok but when command history is longer then F7 helps a lot.


Monday, September 15, 2014

Setting an ALIAS in Windows Command Line

I work mostly on Windows nowadays and spend a good amount of time with Windows Command Prompt. Now there are some commands , some common locations which I usually use or switch to. 

I tried looking on internet and browsing through couple of stackoverflow articles and finally this is how I solved my problem.

We can use doskey (try doskey /? to read more) for solving this problem. Common syntax to use is :

                                               doskey macroname = macrodefinition

Non Persistent Way

Use Case:

I need to frequently go to say C:\Users directory so in general I have to type cd /d C:\Users everytime. This could be a little more pain if the directory paths are very big and not so simple like C:\Users. 

Open Command Prompt and type 

                                 DOSKEY users = cd /d C:\Users





So next time whenever you need to change current directory to C:\Users just type users. It will change your current directory to C:\Users.





If you have a big list of such aliases , then you can even same all the commands in a single 
bat file say (env.bat) and just use the following command to use all the alias stored in that file.

                                              cmd /k PATH_TO_BAT_FILE

Example of a sample BAT file with aliases.





How to use :





But the big problem with this approach is that you need to do these steps everytime you open command prompt So let's see how to do this thing a one time Persistent way.


Persistent Way

Here also you need to create the bat file which will contain all the alias and doskey related information as explained above.

You need to do the following steps:

Run the ‘regedit’ command to fire up the registry editor and add the following data:
  • Key: HKCU\SOFTWARE\Microsoft\Command Processor
  • Value: AutoRun
  • Type: REG_EXPAND_SZ
  • Data: PATH_TO_BAT_FILE_WITH_ALIAS_INFO






Note:
If you want to add arguments to the commands used for alias then you can use $* at the end.

Example:
                                   python3=C:\Python31\python31.exe $*


 If you want to see list of macros defined then use doskey /macros. It will print all the doskey macros.

References: http://technet.microsoft.com/en-us/library/cc753867.aspx