Run a script under alternate user credentials without using
Well, here comes Denis Mission Impossible list:
If the title read by the batch file contains this prefix, it will result in multiple prefixes when restoring the title.
Ive been creating a list of things that cant be done in VBScript.
These real-life challenges come from Denis St-Pierre:
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,
or equivalent to send a Win key combo (i.e. you cant do Win-D or Win-E in VBScript)
ECHOthe wordOFFon screen in a DOS window.
An extra challenge I found was the fact that Windows7 uses Administrator: as a prefix in the title when running with administrator privileges.
I know some people love Mission Impossible stuff.
Found an alternative solution? Very clever!
Detect when Desktop is active (some things dont work until you can see the desktop after you login)
Aalok Narkhede came with this very simple solution to enumerate all subkeys in the root of a registry hive:
FOR /L %%A IN (1,1,5) DO START Test %%A %~dp0GetTitle.bat
To pass my test, multiple instances of each script must run simultaneously without snatching each others titles.
Found this solution or a similar one yourself? Amazing! Try the next one.
The following 3 challenges are to test your (XP) batch scripting skills only.
TYPE root.reg FINDSTR /R /B /C:\[HKEY_USERS\\[\\]*\]
, arrSubkeys For each subkey in arrSubkeys WScript.echo [HKEY_USERS\ & subkey & ] Next Set objReg = Nothing
Read thetitleof the running batch files own window (theTITLEcommand cansetthe title, but sometimes we may want torestorethe original title)
does (found a workaround, , not tested)
Minimize or maximize a specific window
You could even make it a challenge on your web site on finding/producing workarounds for some of them.
windows in taskbar (other than IE windows)
(or equivalent) (Currently this can be done only on remote PCs as perMicrosofts Scripting Guys)
The same challenge again, now alsowithout using quotes!
You didnt find butdounderstand the solution? Not bad, not bad at all!
Nothing more, nothing less, only the wordOFFwithout quotes!
Youll know if you solved them by the fact that you do get the desired results.
If you think you can script, test your skills on some of these challenges.
Found any of these solutions by yourself? Well done!
This might be your opportunity to eternal fame!
In the last line,backspaceis ASCII character 8: a backspace.
To test, I use the following code, located in the directory where GetTitle.bat is located:
The challenge is that you may only use a single command linewithout using ampersands!
That way I dont waist my time trying to code the impossible.
So far,REGEDITseems the only tool that can do this, more or less:
The solutions I received so far all useTASKLIST /Vto get the title.
START /WAIT REGEDIT /E root.reg HKEY_USERS
Get and set the owner of files and folders
Found the solution by yourself? Congratulations, consider yourself a batch file guru!