Rob van der Woude's Scripting Pages

Scripting Challenges

If you think you can script, test your skills on some of these challenges.

Batch File Challenges

The following 3 challenges are to test your (XP) batch scripting skills only.
You'll know if you solved them by the fact that you do get the desired results.

Challenge 1:

ECHO the word "OFF" on screen in a "DOS window".
Nothing more, nothing less, only the word OFF without quotes!

Challenge 2:

Display the following table:

0 0
1 0
1 1
2 0
2 1
2 2
3 0
3 1
3 2
3 3
4 0
4 1
4 2
4 3
4 4

The challenge is that you may only use a single command line without using ampersands!

Challenge 3:

The same challenge again, now also without using quotes!

Real-life batch challenge

Read the title of the running batch file's own window (the TITLE command can set the title, but sometimes we may want to restore the original title)

VBScript Challenges

These real-life challenges come from Denis St-Pierre:

I've been creating a list of "things that can't be done in VBScript".
That way I don't waist my time trying to code the impossible.
You could even make it a challenge on your web site on finding/producing workarounds for some of them.
I know some people love "Mission Impossible" stuff.

Well, here comes Denis' "Mission Impossible" list:

And I would like to add one myself:

This might be your opportunity to eternal fame!

We have a winner!

Aalok Narkhede came with this very simple solution to enumerate all subkeys in the root of a registry hive:

Option Explicit

Const HKEY_CLASSES_ROOT  = &H80000000
Const HKEY_CURRENT_USER  = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS         = &H80000003

Dim objReg, strComputer, arrSubkeys, subkey

strComputer = "."

Set objReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:StdRegProv" )

objReg.EnumKey HKEY_USERS, "", arrSubkeys

For each subkey in arrSubkeys
    WScript.echo "[HKEY_USERS\" & subkey & "]"

Set objReg = Nothing

Besides "", Chr(0) will work as well.

Congratulations Aalok

page last modified: 2016-09-19