Wednesday, 5 February 2014

Tools & Tech - VBScript to make a Custom CMD Window

When we work on the Windows command line, we’ll often set-up the CMD window to our liking. This means a number of commands have to be entered to get in a state to begin the real work.


YouTube Channel: [WATCH, RATE, SUBSCRIBE]

VBScript is a great way to automate simple tasks and have Windows get to a point where we can use it. Setting up the CMD window is no different. By creating a simple VBScript and keeping it handy, we can more quickly get going with our command line tasks.
The first thing is to open a new txt file and enter the code below, save it as a .vbs file in a location of your choice. To run, simply double-click and a customised CMD window will be created.

If you get errors, check items such as cd dev/ruby given this may be incorrect for you system.


Set cmd = CreateObject("WScript.Shell")

' Open a CMD window
cmd.run"cmd"
WScript.Sleep 200

' Go to the root of the drive
cmd.Sendkeys"cd/{Enter}"
WScript.Sleep 200

cmd.Sendkeys"cd dev/ruby{Enter}"
WScript.Sleep 200

'Change the title
cmd.SendKeys"title ##  cyreath.blogspot.com  ##{Enter}"
WScript.Sleep 200

'Clear the screen
cmd.Sendkeys"cls{Enter}"
WScript.Sleep 200

You can also download the script from:
http://www.cyreath.co.uk/blogDownloads/cmd.vbs

In the video, linked to above, there’s also a quick explanation of the items above, along with how to customise the background and text colour. Have a look and get using a little more VBScript!

Mark

YouTube Channel: [WATCH, RATE, SUBSCRIBE]



0 comments: