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

10.08.07

Loops Part VI – For /F

by Jeremy | 4:28 pm


‘For /F’ is my favorite DOS command of all time. Its uses are endless. At it’s core, the /F switch doesn’t sound like much. It reads a file, one line at a time, and assigns the first “token” to a variable. The thing that makes it powerful is modifying how it defines a line, token, and how many tokens it should grab.
Read the rest of this entry »

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

07.20.07

Unique – Remove Duplicates from text list

by Jeremy | 5:21 am


Search the internet and you’ll find a lot of talk about how to take a large list of values and remove the duplicates.  Unfortunately, I haven’t found any good solutions using batch.  I took some time to think about this the other day because I needed the functionality in a larger script.  I came up with two ways to do this.

Read the rest of this entry »

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

06.26.07

Random Numbers

by Jeremy | 10:54 pm


Random numbers can be generated in several ways.  Depending on what you’re using them for, each way has its benefits.  This post will talk about the %RANDOM% variable and using the system clock to generate psuedo-random numbers on the command line.
Read the rest of this entry »

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

Loops Part V – For /L

by Jeremy | 9:52 pm


For /L is used for counting. Need to execute a command X number of times, or have a variable number of cases that each need to be dealt with separately? For /L is your pony.
Read the rest of this entry »

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

06.01.07

Loops Part IV – For /R

by Jeremy | 11:35 pm


This post is fairly short because to tell you the truth, I’ve never used for /r. The functionality offered by this switch can be duplicated with /f if done correctly. That said, why don’t you jump in and explore it with me. As I write this post, I’m thinking about all the things I could have used this for rather than the more complex commands that I ended up using.
Read the rest of this entry »

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

05.07.07

Samsung Camcorder software on Windows Vista

by Jeremy | 9:08 pm


Have an older Samsung Camcorder that you want to use its Motion Capture software on your new Windows Vista PC?  You guessed it, the driver installation doesn’t work.  To get my SCL770 to work, I did the following:

Read the rest of this entry »

Posted in Off-Topic, Windows Vista
-- 1 Comment

« previous | Next Page »
Design by .