News Archives 2017 Q2
is a piece of VBScript code to get the current script (engine)'s Process ID (PID).
The PID is displayed on screen and returned as errorlevel
is a batch file I wrote to check which .NET Framework versions are installed on any specified computer.
Unlike my other similar scripts, that query the registry, this one checks mscorlib.dll's file version, making it suitable (in theory, not tested) to check all .NET Framework versions on all Windows versions since Windows 2000.
Default output is a list of full version "numbers", e.g.:
With the optional
erbose output), the batch file will try to return a description instead of the number, e.g.
.NET Framework 3.5 Service Pack 1 (3.5.30729.01)
instead of just
These descriptions are based on listings from Microsoft Support
and Jonathan Parker
Neither of these listings is complete, several 64-bit versions as well as recent versions are missing.
If the batch file cannot find a description, it will just return
followed by the version, e.g.
.NET Framework 4.7.2053.0
Thanks Jonathan, and thanks Microsoft Support
• Another update for TrueName.exe
: while it still uses DIR /ADL
to find reparse targets
, it now checks the specified path's
reparse points, making it a little faster again.
is the C# implementation of my TrueName.bat
Internally the compiled C# executable uses the same technique that the batch file uses to detect "reparse points": DIR /ADL
The executable is, however, much
faster than the batch file!
• The last couple of weeks my computer would be unusable for at least 20 minutes after logging in: the screen would freeze and/or go blank, and often a message would pop up stating the display driver had crashed and recovered.
I first suspected a recent display driver update, but restoring the old one did not solve the problem.
Then I discovered that multiple backup scripts ran simultaneously, especially if the computer had not been used for more than a day.
This was solved by writing and using RunHidden.exe
instead of RunNHide.exe
, but the performance problem remained.
I started running Task Manager's Processes list full time and full screen on my second monitor to try and find out which processes were involved when the screen froze.
This left me with only 2 suspects: the real-time virus scanner and CompatTelRunner.exe.
Googling for CompatTelRunner.exe I learned that:
- it is (part of) Microsoft's "Application Experience" feature
- it scans all harddisks (6 on my system) on a regular basis
- it is often considered a resource hog (which did not really come as a surprise)
- it seems useless unless I want to upgrade to Windows 10 (which I don't, not on this computer anyway)
- the "cleanest" way to disable it is by disabling all scheduled tasks in "Microsoft\Windows\Application Experience"
I tested disabling the tasks, and the performance improvement was dramatic, so this change is here to stay, at least for now.
As you may have guessed, I wrote a batch file to automate disabling these scheduled tasks: DisableCompatTelRunner.bat
Run it without command line arguments to disable
the tasks, or with the
switch to reenable
has been updated:
- by default, for HTAs only, the special subroutines
Window_OnUnload will not be counted as unused; the new optional command line switch
/W can be used to treat them like ordinary subroutines
- when listing unused subroutines and/or variables only (
/U switch), it will also display the unused count, like the batch file namesake does
has been updated:
- like its C# namesake, the new version checks for unused subroutines as well as unused variables
- the new version no longer skips arrays
- like its C# namesake, the new version can handle VBScript as well as HTA code
- like its C# namesake, the batch file's errorlevel will be -1 on errors, instead of 1, to distinguish 1 unused variable or subroutine from a command line error
If you value performance, however, I would recommend the C# version, which was 200
times faster than the batch file in a test.
• Alfred Adric reported problems when starting VBScript code, located in his "Program Files" folder, with RunNHide.exe
As it turned out, the command line parsing for non-executables removed doublequotes, so I rewrote the command line parsing code.
• I have used RunNHide.exe myself to start scheduled backup scripts for quite some time.
The main disadvantage of using RunNHide.exe was that the task would start the backup script and immediately return errorlevel
0, while the backup script was still running.
Besides no longer being able to verify the backup tasks in the Task Manager window, even worse, I could no longer limit the task to running only a single instance!
So I wrote RunHidden.exe
, similar to RunNHide.exe, except it will wait for the specified command to exit and pass on its errorlevel.
has been updated, it now includes the LPR command and generates its output page in HTML5.
Thanks M. Holzé for the LPR tip
is an improved C# "follow-up" of the batch file of the same name.
I have been working on the batch file lately, but I found it was extremely
slow, so I wrote this (fast) C# version.
The C# version will test VBScript code (pure VBScript or HTA) for declared but unused
subroutines and variables.
It assumes that all variables are declared using
statements; VBScript's own
can handle undeclared
• A bug in Hardware.hta
has been fixed ("variable is undefined" error messages).
And despite promising results so far, today spawned Internet Explorer windows seem to pop up in the background again, instead of in the foreground.
To be continued...
has been updated.
I wrote it more than 10 years ago to get the true path of SUBSTituted or mapped network drives, mimicing COMMAND.COM's internal TRUENAME
The new version of the batch file now also returns the true path for NTFS directory junctions.
To accomplish that, it uses DIR
switch on the specified path, and on its parent folder, and on that
folder's parent folder, etc.
The batch file's junction functionality won't work in Windows NT 4, in that case it will just skip the test, but I doubt that will ever be a problem.
• A minor update for Hardware.hta
- Russell J. Wiley contributed a solution to always open Internet Explorere windows (debug and print dialogs and detailed WMI query results) in the foreground.
- The WMI query responsible for listing all CDROM drives has been modified to exclude all CDROM drives with names containing the word "virtual".
has been updated: it now also includes Windows 10 version 1703's addition MBR2GPT
is a new "wrapper" DLL
for the WINAPI (user32.dll) GetSystemMetrics function.
Its usage in VBScript:
Set ObjMetrics = CreateObject( "RobvanderWoude.GetSystemMetricDLL" )
' Three ways to read property values
WScript.Echo ObjMetrics.GetPropertyValue( "SM_CMONITORS" )
WScript.Echo ObjMetrics.GetPropertyValue( 80 )
' Get the DLL's version
WScript.Echo ObjMetrics.GetVersion( )
' List all available property names
WScript.Echo ObjMetrics.ListPropertyNames( )
' List all property names and their values
Wscript.Echo ObjMetrics.ListPropertyValues( )
' Show this help text
Wscript.Echo ObjMetrics.GetHelp( )
To use this DLL it needs to be registered once; I included a batch file to register the DLL in the ZIP file.
||page last uploaded: 2018-04-16, 14:04