1. Home
  2. Computing & Technology
  3. Visual Basic
photo of Dan Mabbutt
Dan's Visual Basic Blog

By Dan Mabbutt, About.com Guide to Visual Basic since 2002

Save Time and Errors running CScript

Wednesday January 5, 2005

This isn't Visual Basic, but ...

Since the About Visual Basic web site has been featuring a lot of VBScript articles recently, here's a tip that you might really like to see about DOS.

Microsoft recommends that you should run most of their ADSI and WMI VBScripts in a DOS command window using CScript. The reason is that when you execute a WScript.Echo command in Windows, it creates a new window to display the ouput every time. If you run a script that produces a lot of output, you can lock up your machine with thousands of individual windows sooooo bad !!!! I've been tempted to kick the plug out of the wall when it has happened to me.

But to do that, you usually have to navigate to the correct directory to execute your script command. If you're in, for example, "C:\Documents and Settings\Dan\My Documents" and your script is in "C:\Programming Tests\Visual Basic\Scripting Stuff\Scriptomatic" then you have to CD (Change Directory) up to the root and CD all the way back down to the Scriptomatic directory. Because "long file names" are usually used (for you young whippersnappers, old time programmers used to have to think up unique eight character names for EVERY file and directory), this can be a lot of typing and a lot of mistakes.

CD \
CD Programming Tests
CD Visual Basic

and so forth. (I know you could enter it all in one command, but that doesn't actually save many keystrokes and increases the chance of an error.)

Here's a tip ... just use the wild card with the CD command. If the part you do enter is unique, then you've got it.

So ... instead of ...

CD Programming Tests

... enter ...

CD Pro*

It saves me a lot of time when I'm running VBScripts!

Comments

July 4, 2007 at 9:36 am
(1) Peter Bryenton says:

Your 8 character comment reminded me of even farther back in time, when I was coding by hand with a pencil and paper, in HEX. Then there were those lilac and grey Octal bootstrapping switches . . .

I’m an old git :)

July 4, 2007 at 1:13 pm
(2) visualbasic says:

There are a few of us around. I’ve watched people enter bootstrap programs using console switches in binary, but I was just a junior programmer at the time and I was lucky that they didn’t chase me out of the machine room.

Thanks for the comment!

October 23, 2008 at 10:07 am
(3) John Price says:

Something that helps a lot, that was also “borrowed” from Linux, is filename completion. After typing the first character or two of a directory, press TAB to have the shell try to complete it. If it picks the wrong one, keep pressing TAB until it gets the one you want.

October 24, 2008 at 10:57 am
(4) visualbasic says:

Wow! The original blog was written three years ago, but people keep reading it!

I never knew about John Price’s trick! Thanks.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.