Scripting Home

04.28.08

Providing Command-Line Help

by Jeremy | 3:53 pm


Most well-written scripts and programs offer the user some assistance with providing command-line variables/options. Do this in your scripts and you’ll have thankful users, especially if your script gets used by people other than close friends and co-workers. I’ve used many methods over the years of checking for, and branching off and providing help. My favorite though is just a one-liner that checks for a ‘?’ anywhere on the command line.
Read the rest of this entry »

Posted in Batch, Windows 2000, Windows NT 4.0, Windows Vista, Windows XP
-- Comments

04.01.08

Number Format Conversion – Decimal to Hexidecimal

by Jeremy | 10:02 pm


As much as I like batch, it cannot do the simple task of converting a number from decimal to any other format. In my job, I need to convert to hex fairly often. Rather than opening up calc and using it’s clunky format, I found a bit of vbs code from another site and edited it to look good. And since my employer disables running vbs code unless you execute the interpreter, I packaged it up nice and neat in this script.
Read the rest of this entry »

Posted in Batch, Windows 2000, Windows NT 4.0, Windows Vista, Windows XP, vbs
-- Comments

Open a file with its associated program

by Jeremy | 9:39 pm


Have you ever noticed that when you double-click an Excel file, and if Excel was already open, the file you clicked opens in the already running instance? How do you replicate that on the command line? Running “Excel.exe MyFile.xls” opens another instance. Running “Start MyFile.xls” opens another instance of Excel as well. Luckily, Windows exposes the functionality that Explorer uses to start programs, if you only know how to get to it.
Read the rest of this entry »

Posted in Site
-- Comments

Loops Part VII – For /F – To Create Dynamic Menus

by Jeremy | 9:22 pm


Creating menus in batch usually means lots of echo statements to print out the menu, cluttering up what may have been a clean, easy to read script. Using ‘For /F’, you can create a dynamic menu with just a few lines. All you need is a separate file to store the menu options in. This is very handy for menus that you have to change occasionally. It’s easier to change them in that text file than finding the menu in the script and inserting it, which may require you to renumber the rest of the menu.
Read the rest of this entry »

Posted in Batch, Windows 2000, Windows NT 4.0, Windows Vista, Windows XP
-- 1 Comment

|
Design by .