If you think you can script, test your skills on some of these 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.
ECHO
the word "OFF
" on screen in a "DOS window".
Nothing more, nothing less, only the word OFF
without quotes!
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!
The same challenge again, now also without using quotes!
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)
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:
Sendkeys
or equivalent to send a Win key combo (i.e. you can't do Win-D or Win-E in VBScript)RunAs
(or equivalent) (Currently this can be done only on remote PCs as per Microsoft's Scripting Guys)RunDll32.exe
does (found a workaround, see: vbs2exe.com, not tested)And I would like to add one myself:
START /WAIT REGEDIT /E "root.reg" "HKEY_USERS"
TYPE root.reg | FINDSTR /R /B /C:"\[HKEY_USERS\\[ˆ\\]*\]"
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 & "]"
Next
Set objReg = Nothing
Besides "", Chr(0) will work as well.
Congratulations Aalok
page last modified: 2016-09-19; loaded in 0.0016 seconds