MDRSESCO – Software for the Masses


The software described herein, except where otherwise noted, was designed and implemented by MARK DANA ROCKMAN   Email:  usermark at mdrsesco dot biz.  Developed using C# and C++ with .Net Framework and INTEROP aka P/Invoke. Some applications run as Windows NT Services.



BigDigitClock displays the current time-of-day.  This seems trivial, but at a radio station, with three analog clocks, that are supposed to be synchronized with a GPS time-source, but aren’t, this app fills a void.  Together with the KeepClockUpdated daemon, BigDigitClock let’s announcers know when to begin speaking at the start of a live broadcast. [BigDigitClock-BASIC]




Infinite Precision Arithmetic

Sometimes a computer language’s data types are not up to the task.  Suppose you want to compute a very large integer exactly.  For example, what is 2 to the 1000th power?  Enter MPA4 (Multiple-Precision Arithmetic Version 4).  MPA4 carries out integer addition, subtraction, multiplication, and division, correct to the very last decimal place.  It computes integer powers of integers.  It factors integers.  It performs Diffie-Hellman and Mersenne prime computations.  [MPA4]



By the way,  is 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376



Suppose your insurance company will dispense a 90-day supply of medication.  It takes time for a pharmacy to accept a prescription and deliver the tablets.  If you wait 90 days between doctor visits, you may have to live without your meds for a few days.  In the case of serious medical conditions, that could prove to be inconvenient.  Enter Days Between, a utility program in which you enter two dates, to reveal the number of days it will take to get you from the first date to the last date.   When your doctor wants you to come back, make it fewer than 90 days from now.  In this example:  84 days from now.  You get your script and time to have it filled.  No running out of meds. [DaysBetween]




Sometimes you need to upload a large file.  There may be a limit on the number bytes per transmission.  Enter Split/Combine, a utility program that breaks a large file into several contiguous pieces, and later recombines them. [SpilitCombine]




MERGE finds corresponding files in two directory trees and merges them into a third directory.

Some files may appear in one directory but not the other.  These are sent to the output directory.  Those files that appear in both directories are compared to learn which one of the two is the more recent.  The more recent one is sent to the output directory. When files have identical timestamps the longer file is copied. 

MERGE is handy when you maintain several separate but related collections of files, organized into directories and sub-directories.  It sometimes becomes convenient to combine collections through de-duplication. [Merge]




CopyMaster is an app that allows you to duplicate the latest directory structures and files so they appear on two different computers at the same time.  This redundancy has two advantages.  First, there is a current backup copy of your important files.  Second, there is convenience in being able to find all your favorite stuff on at least two different computers. [CopyMaster]


How You Work It

Map the A: drive to \\ComputerOne\C$ and the B: drive to \\ComputerTwo\C$.  Then launch CopyMaster.  When CopyMaster finishes doing what it does do, you’ll have two computers that sport nearly identical contents (ignoring the operating system and extra software files). 

You can create a $.txt file in the C:\Users\Public\$$$DeleteMe directory that instructs CopyMaster to get rid of unwanted directories on both computers.




Suppose you have a directory that contains a florid tree of sub-directories along with files at many levels and you want to be rid of the whole mess.

Windows has a rule that says you may not delete a read-only file.  This prevents you from deleting a directory that contains a read-only file.

Deltree: to the rescue.  Just point Deltree at the root of the mess and it’s gone in three shakes of a lamb’s tail.

Now try doing that with the del or erase command in the ordinary Windows shell.  Oh.  It will do something.   But it won’t do what you want. [deltree]



WAVConcatX takes a collection of WAV files and concatenates them.  It optionally inserts an audio separator between the files.  The output is a single WAV (audio) file made from the contents of the WAV files in the aforementioned collection.

The individual WAV files can exhibit varying attributes.  For example, there is the sampling rate, one channel or two channels, and sample size (8-bit, 16-bit).  You choose the sampling rate and the number of channels in the output file.  WAVConcatX takes care of the necessary conversions. [WAVConcatX]






Downdater for Windows PC


The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences). It differs from problems of finding common substrings: unlike substrings, subsequences are not required to occupy consecutive positions within the original sequences. The longest common subsequence problem is a classic computer science problem, the basis of data comparison programs such as the diff utility, and has applications in bioinformatics. It is also widely used by revision control systems such as Git for reconciling multiple changes made to a revision-controlled collection of files. [DOWN]


A “downdater” is a text file comparison program.  It produces from similar inputs (2 files) a differences file (1 file) that can be applied to the “A” file to produce the “B” file.  Differences are denoted





The lines that follow –N are inserted after line N in file “A”.  The lines that follow –N,M are inserted in place of lines N through M in file “A”.


You can compare two files with DOWN by using the following syntax:


   DOWN <name-of-file-A> <name-of-file-B> <differences-file>


You can compare files in corresponding directories with the following syntax:


   DOWN <name-of-directory-A> <name-of-directory-B> <differences-file>


When comparing directories, the various difference files are separated with a record of the form:




Note that only certain source code and symbolic files are eligible for comparison.   A complete list is available if you send a stamped, self-addressed envelope to the author.


A better way to compare an old folder containing symbolic files with an updated version of the same folder involves a special call to DOWN, followed by execution of a skeleton, followed by execution of a BAT script that calls DOWN repeatedly to create several differences files rather than the single such file that otherwise is produced.  The syntax of the special call is


   DOWN *<name-of-older-folder> <name-of-newer-folder> <name-of-new-differences-folder>


Notice the asterisk that comes before <name-of-older-folder.  This signifies that DOWN is to produce an SSG skeleton in the new-differences-file together with an SGS file to be used with the skeleton.  The skeleton, in conjunction with the stream generation statements, produces a CMD script that builds a DifferencesFolder inside the new-differences folder.  Only those folder pairs that exist and exhibit differences end up in the DifferencesFolder. 


Example:  Run DOWN *first-directory second-directory directory-to-place-skeleton.  Then CD to directory-to-place-skeleton and type RUN.BAT.  This launches a lengthy DOS script that repeatedly calls DOWN to construct a DifferencesFolder, which see.  As part of this mechanism, the tree structures of the first-named directories are compared and differences reported, if any.  This operation requires that you have installed the Symbolic Stream Generator (SSG).


A fourth argument on the command line is optional and may be –N or –R.  You can suppress the Directory Structure Examiner with the –N option.  You can reverse the order of the first two arguments with the –R option.



SIRASM2 takes the output of DOWN and applies it to what is called a base text file to produce an updated text file.  For example, suppose the base file is





And the updated file is





Then DOWN will produce the following differences file




The command

SIRASM2 base diff updated

reproduces the updated file given only the base file and the differences file.  [SIRASM2]



Here is a sample of real-world output.  The asterisk record signifies the following difference records apply to the named file.


Suppose you have a directory (call it Sam) that is populated with project directories.  Each project directory represents a Visual Studio solution to a different problem.  You maintain current and backup copies of Sam.  You work on improving a solution and wonder what changes you ended up making.  Knowing what changes you made can be helpful when you get around to altering the documentation to reflect the changes.  It can be helpful in detecting mistakes.  It can be helpful when you need to create two similar solutions that contain exactly the differences you want.  Here is a command file for doing a massive comparison of Sam with one of its backups:

1.  C:

2.  CD \Users\Public



5.  CD LSA


7.  CD \Users\Public\LSA\F60

8.  .\RUN.CMD

9.  CD \Users\Public\LSA\F60\DifferencesFolder

10.ERASE .\DifferencesFolder.TXT

The command file RUN.CMD is generated by DOWN.EXE.  It invokes the Symbolic Stream Generator that sequentially calls DOWN.EXE for corresponding files in Sam and its backup.  In the end you get a directory named DifferencesFolder that contains one directory for each solution that has undergone non-trivial changes.


IBMCHECK implements the Luhn Algorithm.  It allows you to enter a credit card number and be informed whether it is valid.  You can enter the number as it appears on your credit card, with spaces every four digits, press a button, and the spaces disappear.  The number is copied to the Windows Clipboard for pasting into a text box on some retailer’s website.  Retailer websites typically get upset when you leave the spaces in place. [IBMCHECKCS]



SSG (Symbolic Stream Generator) is an app that compiles a program called a “skeleton” and simultaneously compiles a text file that is filled with Stream Generation Statements (SGSes).  The skeleton contains the logic.  The SGSes contain the data.  The program creates a text file in accordance with directives in the SGSes.  SSG is a handy tool when you want to generate, for example, a lengthy program structure (e.g. a case statement for incorporation within a C++ or C# app) based on a list of things.  I have used it many times for that purpose.  But SSG is capable of doing more complex things.  For example, a commercial software publisher uses it to generate MXML, the language of Adobe Flex, to produce web apps that allow end users to enjoy a Rich Internet Experience.  The SGSes describe what the page or pages are supposed to look like and the skeleton transforms the description into exactly the right MXML for the purpose.  You can RTFM at [SSG]



CORR is the Directory Date Corrector.  Ideally, Windows would ensure the timestamp applied to every directory would reflect the contents of each directory.  The file inside a directory with the latest last-date/time-of-modification would be honored to have its timestamp applied to its enclosing directory or directories.  So that is what CORR does.  Which directories (now called Folders by marketing) get what timestamps is decided by tournament rules.  CORR makes it possible to inspect the folder contents of a folder and decide which folders need further inspection because of recent updates to the files inside. [CORR]



KeepClockUpdated is a service app that ensures the system clock stays accurate, with checks done for accuracy every 5 minutes.  This entails a time source query every 5 minutes.  In one commercial deployment, KeepClockUpdated is responsible for setting the clock on 24 different computers by comparing each computer's clock with a local time source; one that obtains its very accurate reading from GPS satellites.   (The native Windows time setting mechanism only checks the computer maybe once per day.  Its time source is a computer on the Internet.)  All the magic depends on an understanding of the Network Time Protocol (NTP) that communicates via UDP on port 123.  You can set the calendar and time-of-day to an inaccurate value and wait until some multiple of five minutes past the hour arrives on the clock.  From the time source, KeepClockUpdated obtains the date and time and compares them with the computer's own notion of date and time.  When the two are at variance, KeepClockUpdated changes the computer's clock and calendar to match.  KeepClockUpdated is not appropriate to every setting.  For example, you would not properly employ it where the time source is not in the same building complex as the computers that are running the app. [KeepClockUpdated]



WINSVCFILCPY is service app that runs 24/7.  Once a day, at 0300, it copies key files from their usual staging area to a backup staging area. This is done in order to mitigate the risk that the usual staging area, a Microsoft software-based mirrored pair of HDDs, may become useless as a Microsoft software-based RAID-5 cluster did in September 2013. [WINSVCFILCPY]



FileLogger monitors file changes.  It displays them as they occur in real-time.  It keeps a running log of changes and can copy the log to a file if you choose to do so. [FileLogger]






Password Generator generates random passwords.  They are, by default, a mixture of numerals, upper- and lower-case letters.  You specify the length you want up to 40 characters.  You can choose to have only upper-case or only lower-case letters.  A non-alphanumeric character can be randomly inserted if you choose to do so.  The generated password is put on the Windows Clipboard for ease of placement in a textbox on a web page.  These passwords are hard for hackers to guess and that makes them extraordinarily secure. [CSPASSGEN]




File Mover Service (FMS)

FMS is responsible for copying TRV files in folders P1 through P9 from the production computer to the backup computer.  This is in progress all the time, with throttling imposed to limit impact on an Interactive Voice Response application, except during the graveyard shift.  However, see note, below, regarding limitations imposed by an Interactive Voice Response application.  A given file is copied under the condition that the source file is newer than the destination file or when there is no destination file.  For example, suppose \\DIALIN1\P1\1547.TRV is to be copied to \\DIALIN2\P1\1547.TRV .  It follows that copying will occur only when \\DIALIN2\P1\1547.TRV does not already exist and when \\DIALIN2\P1\1547.TRV  time-of-last-write indicates that it is older than \\DIALIN1\P1\1547.TRV .

You can change the direction of copying with the application NamedPipesClient.  Simply connect, then type from-1-to-2 or from-2-to-1 in the Send Message area of the dialog box and press the Send button.  When you switch the phone lines from DIALIN1 to DIALIN2 (or the reverse), you should remember to change the direction of copying.  NamedPipesClient must be run with elevated privileges. [MWE_FMS]








Individual Computer Housekeeping Service (ICHS)


ICHS is responsible for performing three functions:

1.  Midnight Movers

2.  Sunday Movers

3.  Richmond Download

Midnight Movers happens at 29 minutes past midnight every night.  It prepares for the upcoming business day by clearing today’s stories out of their today’s slots and moving them to yesterday’s slots.

Sunday Movers happens at 28 minutes past one o’clock on Sunday morning.  It prepares for the upcoming business week by clearing files from their daily slots and putting them into a weekly backup location.

Richmond Download implements the File Transfer Protocol so as to acquire copies of files 1501.TRV through 1505.TRV, which are voice files from the Richmond Times-Dispatch.  This download occurs daily at five minutes past noon. [MWE_ICHS]







Original P1             Daily Copy To     New P5

1000.TRV-1099.TRV                         1000.TRV-1099.TRV

1100.TRV-1199.TRV                         1100.TRV-1199.TRV

1300.TRV-1399.TRV                         1300.TRV-1399.TRV

1500.TRV-1599.TRV                         1500.TRV-1599.TRV

1700.TRV-1799.TRV                         1700.TRV-1799.TRV

1800.TRV-1899.TRV                         1800.TRV-1899.TRV

2000.TRV-2099.TRV                         2000.TRV-2099.TRV

2100.TRV-2110.TRV                         2100.TRV-2110.TRV

3600.TRV-3620.TRV                         3600.TRV-3620.TRV

3700.TRV-3720.TRV                         3700.TRV-3720.TRV

3900.TRV-3999.TRV                         3900.TRV-3999.TRV

4000.TRV-4099.TRV                         4000.TRV-4099.TRV

4100.TRV-4199.TRV                         4100.TRV-4199.TRV

4500.TRV-4599.TRV                         4500.TRV-4599.TRV

4700.TRV-4799.TRV                         4700.TRV-4799.TRV





Original P6             Daily Copy To     New P6

1000.TRV-1099.TRV                         8400.TRV-8499.TRV

1100.TRV-1199.TRV                         8500.TRV-8599.TRV

3900.TRV-3999.TRV                         8600.TRV-8699.TRV

4000.TRV-4099.TRV                         8700.TRV-8799.TRV

4100.TRV-4199.TRV                         8800.TRV-8899.TRV

1300.TRV-1399.TRV                         8900.TRV-8999.TRV

1600.TRV-1699.TRV                         9000.TRV-9099.TRV

1900.TRV-1999.TRV                         9100.TRV-9199.TRV

1800.TRV-1899.TRV                         9200.TRV-9299.TRV

4500.TRV-4520.TRV                         9300.TRV-9320.TRV

4600.TRV-4620.TRV                         9400.TRV-9420.TRV

4700.TRV-4720.TRV                         9500.TRV-9520.TRV

5100.TRV-5120.TRV                         9600.TRV-9620.TRV

5200.TRV-5220.TRV                         9700.TRV-9720.TRV

5300.TRV-5320.TRV                         9800.TRV-9820.TRV




Per the script that formerly was launched on Sundays:


del from P1 4801-4899",

del from P1 9601-9699",

del from P1 9701-9799",

copy p1 2901-2999 to p1 4801-4899",sb

copy p1 2501-2599 to p1 9601-9699",sb

copy p1 2401-2499 to p1 9701-9799",sb

move p1 2901-2999 to p1 4801-4899",

move p1 2501-2599 to p1 9601-9699",

move p1 2401-2499 to p1 9701-9799",


The indicated files are deleted from the P1 directory, copied from the P1 directory, or relocated away from the P1 directory, in the indicated order.  The sb notation indicates that copying is directed to the SundayBackup directory.


Simple Backup/Restore makes a backup file from a collection of directories.  You choose which directories to backup by specifying a root directory.  The backup file sports the filename extension .SB.  Each backed up file is internally associated with its name and its time of last modification, its length, and unless it is old-format, a CRC.  Data integrity is assured by a Cyclic Redundancy Check, which is applied on a per file basis.  Simple Backup/Restore was developed in response an incident where a commercial file backup app failed when the computer, which it was backing up, failed catastrophically.   The partially readable backup file had to be recovered through the purchase of additional commercially available software that was capable of sifting through a complex, partially corrupted database.  The central concept of System Backup is simplicity.  A partially completed backup file remains readable.  All the work completed up to the point of failure, if any, is fully recoverable without resort to extraordinary means. [SystemBackup]






The Metropolitan Washington Ear, a radio reading service for the blind, offers audio streaming via the Internet.  They moved to their own, dedicated building and infrastructure in 2008.  Their website was not appropriately updated to cater to different audio streaming software.  MARK DANA ROCKMAN developed this page to allow listeners to hear the audio stream.  That formerly was impossible. [MWE_WEB_CLIENT_FOR_AUDIO]




There follows a description of what is nominally a text editor.  It is that and more.  [EditTechnology]

A Complete List of Rockman's Text Editor Commands

v  add

v  annuity

v  append

v  asga

v  asgax

v  begin

v  bmi

v  bt

v  cd

v  change

v  changeall

v  changewholefile

v  climit

v  close

v  commands

v  copy

v  copychg

v  cpumask

v  cwd

v  dcopy

v  delete

v  deleteafter

v  dhold

v  dirsize

v  dnext

v  dse

v  dup

v  easter

v  ej

v  eject

v  elname

v  erl

v  excelhelper

v  exist

v  extract

v  f1

v  filecompare

v  find

v  flist

v  free

v  gather

v  getfilenames

v  getfiles

v  ghp

v  goto

v  head

v  hold

v  hw

v  ibefore

v  insert

v  inuse

v  isadmin

v  kill

v  last

v  lgoff

v  lizard

v  locate

v  ls

v  mdl

v  next

v  o

v  omit

v  opc

v  open

v  opennew

v  own

v  pmask

v  print

v  ps

v  ps1

v  pswdoff

v  putquotesaround

v  pwoff

v  q

v  rb

v  rc

v  replicating

v  retype

v  reverse

v  ro

v  scale

v  select

v  sort

v  sz

v  tab

v  td

v  toc

v  top

v  touch

v  twilight

v  up

v  uro

v  vw

v  wav

v  winplaces

v  wpt

v  write


General Principles

The Rockman Text Editor accepts commands from the keyboard or from a file. The syntax of the shell command is

ed [name-of-file-to-be-edited [name-of-command-stream]]

You can omit both command line arguments, in which case commands can establish what is to be edited, and commands shall originate at the keyboard. You must provide name-of-file-to-be-edited when you want to provide name-of-command-stream.

Commands comprise three parts: 1) the name of the command, 2) option, 3) arguments. Example:

r,11 PAIJ

contains the r command, the option 11, and the argument PAIJ. Only the name of the command is mandatory.

The editor maintains the file that is being edited in area called the memory file.  The content of the memory file can be created from scratch or it may originate in a file in a file system on a device.  The primarily purpose of the Text Editor is to support your efforts to make changes to the memory file.   Eventually, once you are done making changes, the memory file is copied to a file in a file system on a device for long-term storage.

The editor is either in EDIT mode or in INPUT mode. You can switch between modes by entering a blank line. In EDIT mode, you can instruct the editor with commands. In INPUT mode, non-blank lines are successively added to the memory file.

The editor pulls all of the file's text into memory. In memory is where all the editing occurs. At the end of your editing session, it is your choice whether to save any changes that you have made or to discard the changes. Type EXIT to save the changes. Type OMIT to discard them.

While you are editing, keep in mind that there is always a current line, which you can see by typing PRINT.  Navigation throughout the memory file is by line number, which may be absolute (e.g. go to line 5) or relative (e.g. go 5 lines down from here).

The text editor is one of several Rockman's Tools that you may find useful.  The Symbolic Stream Generator allows you to write programs that generate text files based on simple, structured data.  The Downdater allows you to see the differences between text files presented in -n and -n,m notation.  SIRASM2 allows you to apply changes in -n and -n,m notation to a text file in order to obtain a new text file.


Write to

Command Documentation


The add command brings in at the current location additional lines from either of two sources. If you name a text file then the full file is added at the current point in the file being edited. If you don't name a file then lines from the most recent COPY or DCOPY command are added at the same place.


The annuity command creates an amortization table following an interactive query session that requests all necessary data.  You must provide the amount borrowed, the duration of the repayment period in months, the annual percentage rate, the starting year and month.



The append command relocates the current edit point to after the last line in the file being edited. The editor then goes into INSERT mode.


The asga command opens, when possible, the named file in such a manner that another process can also open the file.  The free command closes the file.  Only one file at a time can be open during an edit session.


The asgax command opens, when possible, the named file in such a manner that another process cannot also open the file.  The free command closes the file.  Only one file at a time can be open during an edit session.


The begin command works with the COPY and DCOPY commands to mark the starting line of a copy operation.


The bmi command calculates Body Mass Index for an individual’s height and weight.  It accepts English and metric units values.

·         Format 1: bmi English,5,9,150

·         Format 2: bmi metric,175,68

The first form syntax is bmi English,<height-in-feet>,<height-in-inches>,<weight-in-pounds>

The second form syntax is bmi metric,<height-in-centimeters>,<weight-in-kilograms>



            If your BMI is below 20:

            This indicates a lean BMI, which means you have a low amount of body fat. 

            If you are an athlete, this can be desirable.

            If you are not an athlete, a lean BMI can indicate that your weight may be too low which may lower your immunity.

            If your BMI and body weight are low, you should consider gaining weight through good diet and exercise habits, to increase your muscle mass.


            If your BMI is between 20 and 22:

            This indicates the ideal, healthy amount of body fat, which is associated with living longest, and the lowest incidence of serious illness.

            Coincidentally, it seems this ratio is what many individuals perceive to be the most aesthetically attractive.


            If your BMI is between 22 and 25:

            This is still considered an acceptable range, and is associated with good health.


            If your BMI is between 25 and 30:

            You are considered "Hefty" and should find ways to lower your weight, through diet and exercise. 

            You are at increased risk for a variety of illnesses at your present weight.

            You should lose weight by changing your diet and exercising more.


            If your BMI is over 30:

            This indicates an unhealthy condition, your excess "Prosperity" is putting you at risk for heart disease,

            diabetes, high blood pressure, gall bladder disease and some cancers.

            You should lose weight by changing your diet and exercising more.



The bt command displays the operating system version, the computer name, the time of last system reboot (also called system restart), and the duration of current system uptime.  Additional information about the computing environment is provided in the edit file.  For example, OSArchitecture 64-bit is an environmental factoid that may interest you.


The cd command changes the current working directory to the named directory.


The change command replaces one occurrence of a string with something else. The argument contains the pattern /old-string/new-string/ where the slash is some convenient delimiting character, old-string is a substring to be replaced, and new-string is what the replacement shall be.


The changeall command is identical to the change command except that all occurrences of old-string on the current line are changed.


The changewholefile command is identical to the changeall command except that the entire file being edited is targeted for change.


The climit command limits the range of columns affected by any of the forms of the change command. Specify the left and right column numbers separated by a comma. Example: cli 4,6


The close command causes the editor to write the lines in the memory file to disk and then causes the editor to terminate.


The commands command lists the cannonical names of all the editor's commands in sorted order.


The copy command creates a store that contains the lines between the begin marker and the current line.


The copychg command duplicates a directory tree, including leaf nodes.  The filename extension of the leaf nodes is altered according to specification.  You name the input directory, the output directory, and the new filename extension.


The cpumask command reports the configuration of central processors in the local computer. 




The cwd command displays the current working directory.



The deleteafter command finds a match on the current line, erases the match, and everything to the right of the match.


The dcopy command is identical to the copy command except that the lines that are sent to the store are deleted.


The delete command removes one or more lines from the file being edited starting with the current line. You can specify the number of lines to delete (e.g. DELETE 5). The default number is 1.


The dhold command saves the current line to a special store (named the "hold" buffer) and deletes the line from the file being edited. You can resurrect the line with the dup command.


Suppose you have a folder.  In that folder are several other folders.  These are top level folders.  You want to know how much space the files in those folders occupy.  The dirsize command reports that information.


The dnext command deletes the current line and sets the current line to the line that follows it.


The dse command performs a Directory Structure Examination.  You can detect structural differences between similar directories. A structural difference occurs when a directory or a file appears in one root directory but not in the corresponding place in the other.



The dup command inserts one or more lines at the current position. The lines inserted originate in the hold buffer. You can specify the number of lines to duplicate (e.g. DUPLICATE 5). The default number is 1.


The easter command displays the date upon which Easter next falls.  Based upon an algorithm published as follows:  Copyright (c) Simon Kershaw 1996. All rights reserved.




The eject command causes the operating system to flush the buffers of a removable device and, perhaps, to physically eject the device. The format is ej drive-letter.


The elname command displays the name of the file that is being edited.


The erl command does a patterned extract of records from a comma-separated values file.  The idea is to get rid of the column heading records and various interstitial records that clutter up the file.  You specify, in order, the name of the input file, the name of the output file, the number of records to discard at the start of the file, and the number of records to skip following those records that are retained. The command assumes that retained records boast of a date in MM-DD-YY format in the leftmost column.  Since Excel handles that format inconsistently, the command reformats the date to Month Day, Year format.  For example, 01-02-03 is transformed to “January 2, 2003”.  If you have a text file open when you type in the erl command then the extracted lines end up in the file.  If not, not.  The command to extract retained lines could be:  erl C:\Users\Public\TESTBED.TXT "C:\Users\Public\Outlet.txt" "2" 1


The excelhelper command modifies a comma-separated value file such that those comma-separated fields that (apparently) contain a date are revised to a form that Excel finds unambiguous.  The Excel in Microsoft’s Office Suite 2007 is inconsistent in handling dates of the form MM/DD/YYYY, YYYY/MM/DD, MM-DD-YYYY, and YYYY-MM-DD.  So these are changed to <month-name> <day-of-month>, <year> within double quotes.


The exist command probes the named directory or filename for existence.  The several outcomes are: 1) the name is reported to be a directory, 2) the name is reported to be a file, 3) the system threw an exception when probing the name, 4) the name does not exist in the file system.  These outcomes are according to the .NET Framework which produces different existence results depending on Platform Target, a compilation parameter.  With Platform Target set to x86 you get one answer.  With Platform Target set to x64 you get a different answer.


The exit command causes the editor to write the lines in the memory file to disk and then causes the editor to terminate.


The extract command removes all those lines in the edit file that do not contain the argument pattern.  For example, the command extract InstallUtil.exe leaves the edit file with only those lines that contain InstallUtil.exe.  Matches are case-insensitive.


The f1 command changes routes.rb in a Ruby on Rails application file so that the application uses named routes.


The filecompare commands performs a byte-for-byte comparison of the two files that you name.  The answer is YES or NO.  YES: the two files are identical.  NO: the two files are different.  Suppose some program you’ve been using for years suddenly halts with an addressing exception.  Suppose you have a backup copy of the .EXE file.  Suppose you compare the backup with the production copy.  Then you can assure yourself that the problem is not due to file corruption.


The find command searches the lines following the current line for a matching pattern. In the pattern, space characters match any character at the same relative position on a targeted line. You can use find to locate based on columnar position. When a tab character is defined (see tab command), you can use it as part of the pattern. For example, suppose LMJ appears in columns 11, 12, and 13 respectively. With the tab character set to semi-colon and tab positions set to 11, 21, and 39, the command

find ;LMJ

matches on the first line following the current line that contains LMJ in columns 11, 12, and 13.  The command option specifies the desired number of match occurrences.  The default is 1.


The flist command creates in the current file a complete listing (with headings) of the symbolic files of the named directory.


The free command closes the file that was previously opened with the asga or asgax command.  Just because you open a file with one of these commands doesn’t mean you are allowed to touch the file’s contents.  These commands exist solely to demonstrate how the Win32 file system file open function operates.  The number of links to the file is reported.  This relates to the concept of “hard link,” in which multiple file system name entries point to the same physical file.  It’s a kind of aliasing mechanism.  You cannot open a hard link (an alias) via asga/asgax.  You can open the file that the hard link designates.


The gather command, in a directory tree, aggregates all the files that have the same filename extension.  Syntax:  gather <input-directory-name>,<output-directory-name>,<filename-extension>


The getfiles command enumerates the files in a specified directory.  If you don’t specify a directory, the default directory C:\ is used.  Enumeration depends on the .NET Framework method System.IO.Directory.GetFiles() and its GetDirectories() counterpart.  Certain files for unknown reasons cannot be enumerated this way.


The ghp command has two forms:  ghp true and ghp false.  The command tries to obtain granted privileges with true. The command tries to revoke privileges with false.  All the privileges known at editor build time are entered into the edit file (assuming you’ve provided the name of one) along with YES when granted and NO when revoked.  Windows does not permit just anyone to obtain a granted privilege.  Some privileges are granted to mere mortals.  Some are granted only to deities.  Group Policy governs those privileges that are granted.


The goto command relocates the current position to the line whose number is given. A synonym for goto is simply the line number.


The head command is identical in function to goto 1.


The hold command saves the content of the current line to a special place inside the editor called the "hold" buffer.  You can resurrect the line with the DUP command.


The hw command sets a horizontal window on the file being edited. The window applies to a specified range of columns. For display purposes only, columns outside the window do not appear. Suppose you want to see columns 11 through 21. You enter hw 11 21.


The ibefore command is identical to the insert command except that the line is inserted before the current line.


The insert command inserts a new line after the current line.


The inuse command probes the file you name to see if it is in use by another process.


The isadmin command displays YES when the editor is running with elevated (i.e. Administrator) privileges and NO otherwise.


The kill command terminates the process whose name you specify.


The last command relocates the current position to the last line in the file.


The lgoff command causes the editor to exit without saving the current file and causes the Windows logon session to terminate.


The lizard command programmatically invokes the following command:  cmd /C "dir /B <directory-name>".  The resulting lines are internally collected and separated.  Each line names a directory or a file that appears superficially in the named directory.  System.IO.File.Exists() is called for each file (directories having been filtered out) so as to seek those files that dir enumerates but that System.IO.File.Exists() claims doesn’t exist.  You must name a directory as the first and only argument to the lizard command.


The locate command is similar to the find command except that there is no columnar bias in the pattern. Searching begins with the first line after the current line and is not case sensitive.


The ls command lists the directories and file in the current working directory.


The mdl command maps a drive letter to a share (i.e. a shared directory (also known as a shared folder)).  The argument is of the form <drive-letter> <share>.  Example:  mdl B \\fserv\wpdocsb


The next command relocates the current position to the next line in the file.


The o command is similar to the print command except that printing starts with the line following the current line.


The omit command causes the editor to exit without saving the memory file to disk.


The open command begin a new editing session by loading the named file's lines into memory. The named file must pre-exist.


The opennew command is similar to the open command except that the file need not pre-exist and, if it does, the content of the file is truncated.


The own command reports the owner of the specified directory or file.


The print command prints the current line and the next n minus one lines that follow it, where n is the number stated in the command.  Example:


means print the current line and the 4 lines that follow it.


The ps command reports the names of existing processes.  Any of these could be terminated using the kill command.


The putquotesaround command revises the lines of the current file so that each line is quoted (surrounded by double-quotes) and preceded by the characters TAG followed by a space.  Should a line contain a double-quote character, putting quotes around a quote character would be ambiguous.   You can provide a substitute for such characters as in PQA `.  In this example, the ` character replaces all occurrences of ".  The default substitution is \".


The pwoff command causes the editor to exit without saving the current file and causes Windows to power off the computer.


The rb command causes the editor to exit without saving the current file and causes Windows to reboot (also known as "restart") the computer.


The replicating command is to be used only on Domain Controllers.  It reports the last time various roles were successfully transferred among domain controllers in a domain.  When replication is not happening, there exists a task for the System Administrator to attend to.


The retype command is similar to the insert command except that the line affected is the current line.  The option of the retype command, when present, specifies the column at which the first character of the argument is to be placed.  For example,

r,11 LMJ

leaves alone the content of columns 1 through 10 and puts the argument into the line starting at column 11.


The reverse command reverses the order of the lines in the file. For example, the file 1 2 3 becomes 3 2 1.  Apply the command twice and 3 2 1 becomes 1 2 3.


The ro command takes a directory argument and marks as read-only all the files the directory (and its directories and their directories). The opposite operation is handled by the uro command.


The scale command prints a column scale extending from column 1 through column 80.


The select command performs a case-insensitive search of all the lines in the main memory file and removes all the lines that do not match the target value.


The sort command reorders the lines in the memory file so that they appear alphabetically.


The tab command allows you to establish a tab character and several column stops. This is handy when entering columnar data. For example, if you enter the command

tab ; 11 21 39

then enter the command

i ;LMJ;X11,EDIT$;. Open the EDIT$ packet

you will create a new line with the various segments left-aligned at the indicated column stops.


The td command displays the date and time last written of the file being edited.


The toc command erases the current file in memory and creates a new file in memory that enumerates the directories and files in the named directory.


The top command sets the current line to zero.


The touch command updates the time-of-last-write of the argument file to match the current time. Should the file not exist, it is created with zero content.


The up command sets the current line to the line immediately above (numbered one less than) the current line.


The uro command removes the read-only attribute from all the files in the argument directory (and the directories it contains and the directories they contain).


The vw command sets a vertical window in which appears a subset of lines of the file being edited. If an n-line subset of the file is in the vertical window then the lines are numbered 1 to n and changes that you may apply affect only the lines in the window. You set the vertical window by stating the starting and ending line numbers as in vw 2 4 which saves the entire file to a hidden location and commences editing of the subset. You merge the subset back into the main file by entering vw without arguments.


The winplaces command displays the folderpaths of all the system special folders. When a text file is open it is replaced with a report similar to this:



The wpt command waits for a process to terminate.  Just give the name of the process and wpt loops until the named process disappears from the system. This is handy when you are replacing one version of a Windows NT Service with another.  You can uninstall the service and the system reports the service has been stopped and uninstalled.  But that’s no guarantee that the process has actually halted.  Enter the wpt command that happily delays execution of the installation step until the process is gone.  When you don’t force a delay, it is quite probable the installer will complain that the uninstalled/stopped process is still hanging around and therefore your attempt to install will have terminated in error.


The write command transfers the lines in memory to the named disk file and terminates the editor.


Nutrients to Foods (NTF)


Anybody can look up the nutrients contained within foodstuffs.  But what if you know what nutrients you want?  What foods should you eat to get those nutrients?  The answer is provided by NTF. [NTF]





There are two version of SHUTDOWN.  Both of them work.  The second one fully exercises the Windows API for logging off and for rebooting and powering off the computer.  [SHUTDOWNCS]






This app is much handier than pointing and clicking around Windows’ own user interface for doing what SHUTDOWN does.  In some contexts there is no obvious way to cause Windows to reboot.





Sometimes you just want to see exactly what a file contains.  [FILEDUMP]





A computer that runs 24/7 is responsible for an IVR application.  The application maintains a large set of files inside a directory structure.  There are two kinds of file:  audio and database.  Both kinds are possessed by the IVR application in that they are to be instantaneously available to the IVR application.  Interference from applications outside the IVR application is dealt with severely:  the IVR application reboots the computer.  It deals with every anomaly this way.  There is no log entry documenting the fact that the IVR application has decided to reboot the computer.  We just watch, in horror, as the machine restarts.  It would be convenient for the manager in charge of the IVR application to become cognizant of the situation immediately upon its occurrence.  Enter MWE-DIAL-IN-CRASH-MONITOR, which pings the computer and plays a tune in the event of no response.

Numerous reboots over the years have been described as being due to interference from applications that are outside the purview of the IVR application.  Somebody “locked” the file.  That is to say, some application has opened the file so it can be backed up for good and proper administrative reasons.   Other potential problems revolve around file metadata such as who owns the file, whether the file is compressed, whether the file is read-only, whether the file has other strange attributes like SYSTEM and HIDDEN.  Folklore tells us the IVR application is quite strict as to what attributes a file may be blessed with.  These, we learn, are N (the attribute a file gets when it has no other attributes) and A (the attribute a file gets when it is ripe for being backed up).  All others are forbidden.  When the IVR application finds a tainted file, it reboots the computer.

Folklore isn’t necessarily an accurate reflection of reality.  In actual fact, the IVR application probably reboots the computer only in the event of a file access conflict and for reasons that have nothing whatever to do with the file system, its behavior and contents.  [MWE-DIAL-IN-CRASH-MONITOR]




TRT32 FILE REPAIR aims to change file metadata to conform to the IVR application’s strict attributes rules.  [MWE_TRT32_FILE_REPAIR]




This ASP.NET application allows a web client to upload a file to the ISP that hosts, the website.  The interesting thing about this application is its inability to spend the time or bandwidth on uploading large files.  Supposedly the problem is mitigated with adjustments to parameters contained within Web.config, a text file Microsoft’s web server, IIS, uses to make decisions about how a round trip is to be handled.  Yeah, those adjustments don’t do the trick.  However, for small files, this “app” is quite satisfactory.  FTP is the workaround for large files.


<?xml version="1.0"?>





                <httpRuntime maxRequestLength="409600" executionTimeout="86399"/>

                <sessionState timeout="500100"/>


            Set compilation debug="true" to insert debugging

            symbols into the compiled page. Because this

            affects performance, set this value to true only

            during development.


                <compilation debug="false" targetFramework="4.0">



            The <authentication> section enables configuration

            of the security authentication mode used by

            ASP.NET to identify an incoming user.


                <authentication mode="Windows"/>


            The <customErrors> section enables configuration

            of what to do if/when an unhandled error occurs

            during the execution of a request. Specifically,

            it enables developers to configure html error pages

            to be displayed in place of a error stack trace.


        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

            <error statusCode="403" redirect="NoAccess.htm" />

            <error statusCode="404" redirect="FileNotFound.htm" />



                <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>


        The system.webServer section is required for running ASP.NET AJAX under Internet

        Information Services 7.0.  It is not necessary for previous version of IIS.









In a previous life, MARK DANA ROCKMAN worked on mainframes.  He created DMP for the Unisys (Sperry) mainframe, which is now known as Unisys ClearPath but previously was known as the Univac 1100/2200 Series.  DMP persists and Les Leist, with whom the aforementioned Rockman once worked, has kindly decided to maintain it and distribute it to those who want it.


DMP 22R2F - Interactive, Multi-Functional Utility Processor .....[06 NOV 2013 (1405 KB) -- Downloads: 878]

DMP is a versatile program with numerous commands relating to system, MCT, and directory information; and utility functions for files and tapes. This version has been upgraded for the latest MCT, MFD, and Audit Trail structures.

*** Although DMP has commands that work with @COPY,G tapes, DMP does not support the newer @COPY,G format with more than one track per block. There is also limited LPF and LEPF support. See DMP/README. ***


-- Written by Mark Rockman. Enhanced by Les Leist.

(DOC no longer posted; obtain from download.)


How to Kill a Process

Your application craves to terminate another process.  Here is how to do it.

namespace EditTechnology


    public class kill


        public static bool WasteHim(String whomToWaste)   // true indicates the process was found and kill was called on it


            string whomWeGonnaWaste = whomToWaste;

            System.Diagnostics.Process[] localAll = System.Diagnostics.Process.GetProcesses();

            foreach (System.Diagnostics.Process p in localAll)


                if (p.ProcessName.Equals(whomWeGonnaWaste))



                    return true;



            return false;  // process by the specified name was NOT found





Notice that what is going on here is enumeration of all the processes in the system.  One of those may have a name that matches the argument.  It is the one, if such exists, that gets the axe.


How to Launch a Process

class Launch


        public bool Process(string nameOfFile)



            System.Diagnostics.Process myProcess = new System.Diagnostics.Process();




                // Get the path that stores user documents.

                string myProgramFilesPath =



                myProcess.StartInfo.FileName = myProgramFilesPath + "\\NOTEPAD.EXE";

                myProcess.StartInfo.Arguments = nameOfFile;

                myProcess.StartInfo.Verb = "Open";

                myProcess.StartInfo.CreateNoWindow = true;





                return false;


            return true;



How to Launch a Process and Gather Its STDOUT


This shows how to launch a console program (a program that can be found among the directories that are listed in the PATH environment variable of the logged-in user’s profile) and have its output sent to a string variable.  The lines of output are separated by carriage returns and/or line feeds.




How to Determine If a File Is Already Open in Another Process






How to Disable the Dismiss Button

You Know.  The X in the Rectangle in the Upper Right of a Window


In a Windows Forms application it is possible to disable the dismiss button.  You must override an event-handling method of the form class and set a flag that tells the powers-that-be that you find it utterly inconvenient to terminate the program at this time.  Probably it would formally be better if you coded a base.OnClosing() method invocation for the case where bWorkerRunning is false.  But it seems that’s not really necessary.  Setting Cancel in eventargs to true does the trick.




Interoperability:  Hooking Managed Code to Unmanaged Code

Managed code is produced by Visual Studio for consumption at runtime by a Just-In-Time (JIT) compiler.  The JIT Compiler transforms Intermediate Language (IL) to machine code and performs runtime checks for type safeness and validity to ensure proper operation and security.  IL is code written for a machine that hasn’t been realized in hardware but is code that can readily be transformed to machine code.  Code that is written in languages such as C# and Visual Basic becomes IL before it becomes machine code.

Interoperability (INTEROP) is the mechanism that enables the methods in managed code to call the methods in unmanaged code. 

Unmanaged code is produced by Visual Studio for languages like C++.  This is direct-to-machine-code compiling.  The only validity checks are the ones that are performed during compilation.  C++ programs are ready to load and execute.  There is no JIT compiling.  There is a variation of C++ that can be compiled to IL and which uses the Common Language Runtime of the .Net Framework, the same as C#.  Why use unmanaged code?  It is because a C++ program is the place where you have access to the entirety of the Win32 API.  Many operating system features are virtually inaccessible from managed code. There is no support in CLR, for example, that lets a programmer instruct the operating system to reboot itself.  Named pipes?  There is nothing in CLR for those.  But Win32 and INTEROP provide the solution.  In the case of named pipes, there is no need for a DLL.  INTEROP takes care of the whole problem.

Consider the case where a Win32 method must be invoked in order to complete the requirements of a C# application program.  The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to a number of different platform implementations that are often referred to by their own names (for example, Win32 API).

INTEROP entails marshaling of arguments and of a return value.  A programmer writes the Win32 method in C++, compiles it into a Dynamic Link Library with a specific release of Visual Studio, and chooses whether the DLL is targeted for a 32-bit or a 64-bit environment.  Another programmer writes C# code that calls the Win32 method.  In C# the programmer must declare the external method and decorate the declaration which names the containing DLL and its location in the file system.  When deploying the solution, the end user must be provided with the C# executable (the .EXE file), the C++ dynamic link library (the .DLL file), and instructions on which Visual C++ Redistributable Library must be installed to make a home convivial to INTEROP and Win32 executable code. 

The made-up term bitness refers to machine and operating system architecture: 32-bit or 64-bit.  The Intel 80386 and follow-on products are 32-bit platforms.  Advanced Micro Devices invented what became the industry standard 64-bit architecture, well after Intel’s introduction of its proprietary 64-bit Intel Itanium Architecture.  See Intel now also manufactures in accord with the Advanced Micro Devices’ design.  When 64-bit is referenced, the architecture that springs to mind is the AMD one, not the Intel one; although they persist and co-exist.  Windows operating system SKUs come in 32-bit and 64-bit flavors.  Either of these can be installed on 64-bit hardware platforms.  On 32-bit hardware platforms only 32-bit Windows can be installed.  Visual C++ Redistributable Library comes in 32-bit and 64-bit flavors.  (The 64-bit flavor can be used only on computers that are running a 64-bit version of Windows.)  There are several versions of Visual C++ Redistributable Library that are individually associated with specific Visual Studio releases.  The Visual Studio release is the one that is used to compile the unmanaged code.  Some combination of Visual Studio release, Visual C++ Redistributable Library, 32-bit/64-bit compilation choice, hardware platform bitness, and operating system bitness can be found that will support successful INTEROP calls.

                catch (Exception emode)  //  An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000b)

                                         //  On January 20, 2015, it was discovered that the ONLY problem was that the default 32-bit DLL was the "incorrect format."  The system demands a 64-bit DLL. 

For the latest revisions to Windows Server (starting with Windows Server 2012), the required runtime libraries are termed “features” of the operating system.  You should install runtime libraries via Server Manager’s Install Feature function.


Here is how C# is used to declare an external C++ method for calling via INTEROP.


Notice this declaration not only declares the name, arguments, and return type of the method, but it also declares the file system location of the containing Dynamic Link Library.

Here is how C# calls the unmanaged method.  The declaration makes this syntactically and semantically legal.


Finally, here is the unmanaged C++ code that could, if it wanted to, call any of the various Win32 methods.


Here is a real-world C++ method that allows a C# application to reboot the computer.




1.    The bitness of the hardware.

2.    The bitness of the operating system.

3.    The bitness of the compiled DLL.

4.    The version of Visual Studio that is used to compile the DLL.

5.    The version of the Visual C++ runtime redistributable library.


MS973190 is a document that claims Visual Studio C#, which generates managed code, can be told to target 32-bit systems or 64-bit systems.  On a 64-bit system the Just-In-Time compiler will produce 64-bit code if that is targeted or 32-bit code if that is targeted.  Windows-on-Windows (WoW64) takes care of non-native cases.  So sometimes your managed code wants a 64-bit DLL for its unmanaged code.  Sometimes it wants the 32-bit DLL.  It’s may be (no guarantee) just a matter of the highly obscure configuration settings in your Visual Studio build.



How to Create a Dynamic Link Library in Visual Studio 2010


To create a new dynamic link library (DLL) project



1. On the menu bar, choose File, New, Project.



2. In the left pane of the New Project dialog box, expand Installed Templates, Visual C++, and then select Win32.



3. In the center pane, select Win32 Console Application.



4. Specify a name for the project—for example, MathFuncsDll—in the Name box. Specify a name for the solution—for example, DynamicLibrary—in the Solution Name box. Choose the OK button.



5. On the Overview page of the Win32 Application Wizard dialog box, choose the Next button.



6. On the Application Settings page, under Application type, select DLL.



7. Choose the Finish button to create the project.



The Care and Feeding of Named Pipes in Services

In computing, a named pipe (also known as a FIFO for its behavior) is an extension to the traditional pipe concept on Unix and Unix-like systems, and is one of the methods of inter-process communication (IPC). The concept is also found in OS/2 and Microsoft Windows, although the semantics differ substantially. A traditional pipe is "unnamed" because it exists anonymously and persists only for as long as the process is running. A named pipe is system-persistent and exists beyond the life of the process and can be deleted once it is no longer being used. Processes generally attach to the named pipes (usually appearing as a file) to perform inter-process communication.

A named pipe is a message conduit.  It bi-directionally conducts messages between processes.  Program A and Program B can connect to a named pipe and send messages to each other without involving rotating magnetic memory devices.  All the magic happens in software and in main memory.

Named pipes are especially handy when it becomes necessary to communicate with daemons, also-known-as Windows NT Services.  The term daemon is popular in Unix and is almost unknown in Windows, but the concept is the same.  A daemon is a program that generally starts automatically after a reboot and runs constantly.  It runs independently of a shell or graphical user interface, which makes it hard to communicate with them.  Enter named pipes.  With named pipes, an application that possesses a user interface is able to send and receive messages to and from a daemon.

The daemon implements a named pipes Server that is constantly watchful for Clients that wish to connect to the Server.  Independent Client sessions are thereby established and lines of communication opened.



 * The Server


 * The purpose of The Server is to maintain and service a collection of clients who connect via a mechanism known as Named Pipes.

 * There is no .NET API for Named Pipes.  So The Server uses System.Runtime.InteropServices to call the necessary Win32 APIs.

 * Fortunately, the APIs are not too complicated nor demanding.  The Named Pipes methods are CreateNamedPipe and ConnectNamedPipe.

 * These are defined by the Windows Dynamic Link Library file kernel32.dll.  The trick is in parameterizing the calls correctly.

 * Named Pipes is the perfect mechanism for communicating with a Windows Service.  A Windows Service is a process that Windows

 * starts at boot time.  There is no conventional user interface.  For example, a Windows Service has no shell and no GUI.


 * The Server maintains a non-generic List (a collection) of Client objects.  The Client object is a non-behaving structure that

 * represents an individual connected client by Named Pipes handle and Filestream, if any.


 * The Server sends messages to users via an event mechanism.  Users register a method that is called when

 * The Server sends a message that it has received from a client. 


 * Users of The Server are able to send messages.  When this happens, each of the connected clients is destined to receive the message.

 * Said users send messages to The Server via the SendMessage() method of The Server.


 * The Start() method of The Server gets things going by forking a thread to field messages that clients send to The Server.

 * The aforementioned thread is called The Listener because it "listens" for clients to "speak."  The Listener is a

 * perpetual loop that exits only when a Named Pipes error occurs or because somebody calls the Stop() method of The Server.

 * On each pass of the loop The Server calls CreateNamedPipe to obtain what is called a Client Handle.  This call blocks

 * until a client connects or until Named Pipes (the complex of software) decides that blocking forever would be futile.

 * For example, the process may be exiting.  In that case, CreateNamedPipe returns an invalid handle, which is detected and

 * handled by The Server by terminating The Listener thread.  Normally, CreateNamedPipe returns a valid handle and this

 * represents a connecting client that usually may be found running in a separate process.  The method ConnectNamedPipe is

 * called to complete the connection between client and server.  Should this error, The Server terminates The Listener.

 * In the usual case of "no error," The Server creates a new Client object and puts the handle in it.  Then The Server

 * locks the client list and adds the Client object to it in one atomic action.  Finally, The Server forks a thread to handle

 * the arrival of messages from the client.  The Reader (as represented by the Read() method of The Server) is passed a

 * reference to the aforementioned Client object.


 * The Read() method of The Server creates a FileStream object based on the handle in the Client object that The Listener passes.

 * Then The Reader enters a perpetual loop that terminates upon the occurrence of an error condition or the Stop() method is called.

 * A reference to the FileStream is put in the Client object next to the handle and the FileStream Read() method is called.

 * This call blocks until a message arrives or an error condition arises.  A zero length message is an error condition that may

 * occur after the client disconnects.   In the normal case, bytes arrive and must be dispatched via an event to the user of

 * The Server.   The bytes are first converted to a string.  In the error case, the handle is closed, the stream is closed,

 * and the client object is removed under lock from the client list.  The Reader thread is then terminated.


 * The user of The Server is responsible to provide the name for a Named Pipe that matches the name that clients will use.

 * For example, if X is a reference to The Server object then X.PipeName can appear to the left of the assignment operator to

 * receive a string of the form \\.\pipe\<name-of-pipe>.  The user then must register a method to handle message arrival events.

 * As before, X is a reference to The Server object.  So X.MessageReceived can appear to the left of the delegate add operator.

 * The assignment is of a delegate instance that points to a method that shall be invoked by The Server when a message arrives.

 * The method receives two arguments in the following order:  1) a reference to the client object, and 2) the message as a string.


 * The user of The Server is in full control of the life of The Server.  Life begins with initialization and Start() and ends

 * with Stop().





Solving Mysterious System Crashes



Suppose your computer performs some vital function and it reboots during peak usage periods for unknown reasons.  You’d like to know why, wouldn’t you?  Enter the system dump and dump analyzer.  To enable Windows to take a dump you must configure Windows to do so.  Ideally you will collect as much data possible in order to allow the dump analyzer the greatest opportunity to spell it out for you.  Microsoft provides some guidance on how to size the page file since that file receives the memory dump during the crash.  See


According to that document you should configure the page file by following to the formula A+B, where A is the amount of main memory in the computer’s hardware and B is 257,000,000 bytes.  B is space required to accommodate symbol tables and headers for the various portions of the dump.  Ideally your computer will take a full system dump when a crash occurs.  The other options are “no dump at all,” and “a minidump.” 


If your system is crashing and you cannot find a dump file (filename extension .dmp) then likely your page file is too small.  On a Windows XP machine with 2GB of main memory 4GB (the maximum allowed) of page file should be plenty.


Usually that which causes system crashes is third-party device drivers that contain faults and issues.  Imagine a linked list that contains an invalid address in one of its pointers.


Microsoft provides WinDbg, a dump analyzer.  There is a commercial product known as WhoCrashed that also provides dump analysis, perhaps in a manner accessible to mere mortals.  Visit their website at


Latest version: 5.03

WhoCrashed reveals the drivers responsible for crashing your computer



Whenever a computer running Windows suddenly reboots without displaying any notice or blue screen of death, the first thing that is often thought about is a hardware failure. In reality, most crashes are caused by malfunctioning device drivers and kernel modules. In case of a kernel error, most computers running Windows do not show a blue screen unless they are configured to do so. Instead these systems suddenly reboot without any notice.


WhoCrashed shows the drivers that have been crashing your computer with a single click. In most cases it can pinpoint the offending drivers that have been causing misery on your computer system in the past. It does post-mortem crashdump analysis and presents all gathered information in a comprehensible way.


Normally, debugging skills and a set of debugging tools are required to do post-mortem crash dump analysis. By using this utility you do not need any debugging skills to be able to find out what drivers are causing trouble to your computer.


MARK DANA ROCKMAN offers no endorsement of this product and is in no way liable for problems you may have using it, if any.


Core Dump in Windows?


Back in the day, a failing computer program would leave behind pages and pages of numbers called a core dump.  It was just a memory picture which, along with register contents, could be used, occasionally, to discern why a program failed.  Such a thing is rarely used these days what with Integrated Debugging Environments (IDEs) that allow you to step through problematic code and fix it all in one go.  However, it is nice to know that Windows admits the possibility that you want to take a core dump.  Here’s how you do it.  Assuming the failed program is still in memory (it may be displaying an error message), find it in Task Manager, right click the item, click Create Dump File.  Et, voilà.  You’ve got yourself a minidump in the %TEMP% directory.  You can then launch Visual Studio and drag the minidump’s icon to Visual Studio’s window in order to visualize the dump.





WinDbg is good for many things.  Among those things is using it as a dump analyzer for when you are able to cajole Windows into producing a dump file such as MEMORY.DMP.  You get a switch to throw that picks the kind of dump to be produced.  You get a number to specify that establishes the size of the Windows Page File.  To produce a full memory dump after an unfortunate computing event (i.e. a crash), the page file will have to be larger than the number of bytes that physical memory will hold.  Naturally, a memory dump has metadata alongside a clump of bytes.  If you have 2GB of physical main memory then 4GB of page file should be more than adequate.  You can leave page size management up to Windows to perform, but the question remains whether Windows is up to the task, especially when the object of the game to is to guarantee that a panic dump is available in the event of a crash.


In order for dump analysis to work correctly, WinDbg requires the symbol table that is created by Microsoft when it does the RTM build of Windows.  You require a specific symbol table for the specific Windows build that produced the dump.


Naturally, this issue progresses to questions such as 1) Where do I get WinDbg and 2) Where do I get the symbol table?  Also, if I get the symbol table, where does the symbol table get put by the symbol table installer?  The installer makes a Federal case out of copying a file, a set of files, and/or database and neglects to mention where it is located.  _NT_SYMBOL_PATH is an environment variable (you may want to create it) that translates to a string that names the location of the symbol table if you knew where that might be.


It can be reliably reported that WinDbg comes with the Windows Driver Kit, which you can download at no cost to you.  And symbols are readily available at


Download Windows Symbol Packages




According to PROCMON, a delightful tattletale, the place where the symbols installer puts all those PDB files is C:\Symbols.  So you should go to Advanced Settings and equate _NT_SYMBOL_PATH to C:\Symbols.


You might also try setting _NT_SYMBOL_PATH to the following




This last one takes the prize cake.  It turns out that symbol tables for the exact build you are running are almost impossible to find.  To fix that little conundrum there exists a way for your favorite debugger (I love WinDbg) to satiate its craving for symbol tables by drinking from the online fountain in The Cloud.  That “DownStreamStore,” above?  That’s The Cloud.  So my recommendation is that you set _NT_SYMBOL_PATH to the aforementioned value.  You get far less complaint from WinDbg about undefined symbols.



Process Monitor and WireShark


Process Monitor, by Mark Russinovich and Bryce Cogswell.


This splendid “app” displays and preserves a comprehensive record of actions internal to Windows.  For example, you can watch various processes open and close files, attempt to communicate on the Ethernet, and play around with The Registry. When the system is complaining about odd things, Process Monitor steps in to explain.  If you don’t find Process Monitor does enough to satisfy your need for Ethernet monitoring, I suggest you use WireShark:


Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. It combines the features of two legacy Sysinternals utilities, Filemon and Regmon, and adds an extensive list of enhancements including rich and non-destructive filtering, comprehensive event properties such session IDs and user names, reliable process information, full thread stacks with integrated symbol support for each operation, simultaneous logging to a file, and much more. Its uniquely powerful features will make Process Monitor a core utility in your system troubleshooting and malware hunting toolkit.


These tools are free of any charge.  And very, very useful.








Do Not Block the Message Pump






The message pump drives the “app.”  Without messages flowing, the program stops behaving.  That is to say, there is no behavior.  You, the end user, see a Not Responding message.  That means the “app” is not processing what may well be a lengthy queue of messages.  That’s because the “app” is busy doing things other than processing messages.  Solution?  While you think the purpose of your program is to solve a business problem, Windows knows better.  The real purpose of your program is to process messages.  So you must create a thread to handle the business problem.  The initial thread thus is dedicated to handling messages.









Configure Domain Name Service (DNS)


From time to time, one is required to create a Domain Controller.  Many Domain Controllers are Domain Name Servers (DNS).  A DNS is responsible for transforming a symbolic Internet or LAN reference to an IP address.  The necessary steps are few and simple and yet the written material is long, complicated, and jargon-laden.  If you get it wrong, your DNS will be resolving symbolic references via the wrong servers out on the Internet.  That’s slow, inefficient, and, in egregious cases, illegal.


Modern Windows Server operating systems offers DNS that is integrated with Active Directory (AD).  That means when you have multiple domain controllers (in the same domain), that DNS is replicated across all of the Domain Controllers.  AD is a database that facilitates coordination between Domain Controllers and allows workstations to become “members” of the domains that Domain Controllers are responsible for protecting and serving.  A hugely important offering of Domain Controllers (DC) is Group Policy.  Group Policy, it need be pointed out, is not Policy that applies to Groups.  Rather, it is a grouping of policies.  The big deal about Group Policy is that is implements the means to set policy for member workstations from a central location.  The central location is the Domain Controller.  You insist, for example, that your workstation users employ complex passwords that expire every month?  Bingo!  No problem.  Just set a policy that says so. is a document that explains how you configure a DNS.  It is very good, but incomplete.  It will get you going with name resolution on your LAN.  That way, computers on your LAN can find each other.  Symbolically.  If your domain does not extend beyond your LAN, you establish an arbitrary domain name such as  All of your member workstations will be “joined to the domain” and named <name-of-computer>.<domain-name>.  For example, 


The following instructions apply to Windows Server 2012 R2.  Previous incarnations of Windows Server sported a DNS configuration utility that was not integrated within Server Manager.  Nowadays one must start Server Manager and navigate its user interface to perform any administrative function.  To get started, the DNS role must be configured.  Launch Windows Server (it usually launches by itself when you restart the server).Click Manage > Add Roles and Features > Role-based or Feature-based Installation > Select a server from the pool > Server roles > DNS Server.  You just tick the checkbox next to DNS Server and follow the instructions that start the installation of the DNS role.  Once that is done, you are ready to configure DNS.  To do that, go back to Server Manger.  Click Tools > DNS.  By clicking DNS you cause to launch what is called DNS Manager.  That is your window onto the world of the Domain Name Service.


Notice the menu across the top of DNS Manager.  One of the menu items is Action.  Click Action > Configure a DNS Server.  This launches a “wizard” that guides you through the process of creating the DNS configuration. You choose to configure a) a Forward Lookup Zone, b) both Forward and Reverse Lookup Zones, c) Neither Forward Nor Reverse Lookup Zone.  Item c) is a bad choice because all name resolution is then done via top-level domain (TLD) name servers and those servers are not designed to nor capable of being Mister Answerman for every workstation in the Universe.  You want at least a Forward Lookup Zone and preferably Forward and Reverse.  Press the radio button that applies in your case. Do you want to create a Forward Lookup Zone now?  Answer yes.  Do you want a Primary Zone?  A Secondary Zone?  A Stub Zone?  Pick Primary.  Tick the Store the Zone in Active Directory checkbox.  Select how you want Zone Data replicated.  You want it replicated far and wide.  Throughout the domain or throughout the forest of domains. I suggest To all DNS Servers throughout the domain.  Now you get to pick your Zone Name.  In my case the Zone Name is  Now you get to choose whether Dynamic Updates are to occur.  It’s a convenience feature.  When a new workstation appears on the LAN and points to the DC/DNS, the DNS recognizes the need to list the workstation so that other workstations on the LAN can communicate with it.  Failing to allow Dynamic Updates means you will be required to manually configure each workstation.  I suggest that you chose to have DNS perform Dynamic Updates. These can be Secure or Not Secure.  Since your DNS database is integrated within AD, you want secure updates.  Now you want to create a Reverse Lookup Zone.  Such a Zone provides the capability to take an IP address and map it to a corresponding symbolic name.  Given you may get, for example,  Do you want a Primary Zone?  A Secondary Zone?  A Stub Zone?  Pick Primary.  Tick the Store the Zone in Active Directory checkbox.  To All DNS Servers throughout the domain. Next, do you want to resolve IPv6 addresses?  Certainly not.  Not on a LAN.  Choose IPv4.  Next, enter the Network ID that applies to your domain.  Suppose all of the computers on your LAN sport an IP address of the form 192.168.1.x, where x varies according to which computer you are considering and is unique to that computer out of all the computers on the  LAN.  The network portion of the IP address is 192.168.1.  So enter that as your Network ID.  This assumes your subnet mask is  Do you want Dynamic Updates?  Yes.  Should this DNS Server forward queries?  Of course it should. Choose the radio button next to that option and enter the IP addresses (or the equivalent symbolic names) of the Domain Name Servers out on the Internet that your Internet Service Provider has kindly documented for you.  Congratulations!  You are done.


When you need to alter the list of Forwarders, go to the Menu and click Action > Properties.  See the tab-laden dialog box.  Choose the Forwarders tab, click Edit and enter the IP address or symbolic names of the forwarders. Then click OK.  See


I find it comforting to know that DNS is successfully contacting the Forwarders, so I use a packet sniffer as I enter a bogus URL in my favorite browser.  Yes, indeed.  The DNS is contacting the Forwarders.  Done and done.



rem Run this as Administrator (i.e. elevated privileges)

dnscmd /ResetForwarders /help

dnscmd /ResetForwarders /TimeOut 5





REM In future versions of Windows, Microsoft might remove dnscmd.exe.


REM If you currently use dnscmd.exe to configure and manage the DNS server,

REM Microsoft recommends that you transition to Windows PowerShell.


REM To view a list of commands for DNS server management, type

REM "Get-Command -Module DnsServer" at the Windows PowerShell prompt. Additional

REM information about Windows PowerShell commands for DNS is available at



REM Usage: DnsCmd <ServerName> <Command> [<Command Parameters>]


REM <ServerName>:

REM   IP address or host name    -- remote or local DNS server

REM   .                          -- DNS server on local machine

REM <Command>:

REM   /Info                      -- Get server information

REM   /Config                    -- Reset server or zone configuration

REM   /EnumZones                 -- Enumerate zones

REM   /Statistics                -- Query/clear server statistics data

REM   /ClearCache                -- Clear DNS server cache

REM   /WriteBackFiles            -- Write back all zone or root-hint datafile(s)

REM   /StartScavenging           -- Initiates server scavenging

REM   /IpValidate                -- Validate remote DNS servers

REM   /EnumKSPs                  -- Enumerate available key storage providers

REM   /ResetListenAddresses      -- Set server IP address(es) to serve DNS requests

REM   /ResetForwarders           -- Set DNS servers to forward recursive queries to

REM   /ZoneInfo                  -- View zone information

REM   /ZoneAdd                   -- Create a new zone on the DNS server

REM   /ZoneDelete                -- Delete a zone from DNS server or DS

REM   /ZonePause                 -- Pause a zone

REM   /ZoneResume                -- Resume a zone

REM   /ZoneReload                -- Reload zone from its database (file or DS)

REM   /ZoneWriteBack             -- Write back zone to file

REM   /ZoneRefresh               -- Force refresh of secondary zone from master

REM   /ZoneUpdateFromDs          -- Update a DS integrated zone by data from DS

REM   /ZonePrint                 -- Display all records in the zone

REM   /ZoneResetType             -- Change zone type

REM   /ZoneResetSecondaries      -- Reset secondary\notify information for a zone

REM   /ZoneResetScavengeServers  -- Reset scavenging servers for a zone

REM   /ZoneResetMasters          -- Reset secondary zone's master servers

REM   /ZoneExport                -- Export a zone to file

REM   /ZoneChangeDirectoryPartition -- Move a zone to another directory partition

REM   /ZoneSeizeKeymasterRole    -- Seize the key master role for a zone

REM   /ZoneTransferKeymasterRole -- Transfer the key master role for a zone

REM   /ZoneEnumSKDs              -- Enumerate the signing key descriptors for a zone

REM   /ZoneAddSKD                -- Create a new signing key descriptor for a zone

REM   /ZoneDeleteSKD             -- Delete a signing key descriptor for a zone

REM   /ZoneModifySKD             -- Modify a signing key descriptor for a zone

REM   /ZoneValidateSigningParameters -- Validate DNSSEC online signing parameters for a zone

REM   /ZoneSetSKDState           -- Set Active and/or Standby keys for a signing key descriptor for a zone

REM   /ZoneGetSKDState           -- Retrieve dynamic state for a signing key descriptor for a zone

REM   /ZonePerformKeyRollover    -- Trigger a key rollover in a signing key descriptor for a zone

REM   /ZonePokeKeyRollover       -- Trigger a key rollover in a signing key descriptor for a zone

REM   /ZoneSign                  -- Signs the zone using DNSSEC online signing parameters

REM   /ZoneUnsign                -- Removes DNSSEC signatures from a signed zone

REM   /ZoneResign                -- Regenerate DNSSEC signatures in a signed zone

REM   /EnumRecords               -- Enumerate records at a name

REM   /RecordAdd                 -- Create a record in zone or RootHints

REM   /RecordDelete              -- Delete a record from zone, RootHints or cache

REM   /NodeDelete                -- Delete all records at a name

REM   /AgeAllRecords             -- Force aging on node(s) in zone

REM   /TrustAnchorAdd            -- Create a new trust anchor zone on the DNS server

REM   /TrustAnchorDelete         -- Delete a trust anchor zone from DNS server or DS

REM   /EnumTrustAnchors          -- Display status information for trust anchors

REM   /TrustAnchorsResetType     -- Change zone type for a trust anchor zone

REM   /EnumDirectoryPartitions   -- Enumerate directory partitions

REM   /DirectoryPartitionInfo    -- Get info on a directory partition

REM   /CreateDirectoryPartition  -- Create a directory partition

REM   /DeleteDirectoryPartition  -- Delete a directory partition

REM   /EnlistDirectoryPartition  -- Add DNS server to partition replication scope

REM   /UnenlistDirectoryPartition -- Remove DNS server from replication scope

REM   /CreateBuiltinDirectoryPartitions -- Create built-in partitions

REM   /ExportSettings            -- Output settings to DnsSettings.txt in the DNS server database directory

REM   /OfflineSign               -- Offline signing zone files, including key generation/deletion

REM   /EnumTrustPoints           -- Display active refresh information for all trust points

REM   /ActiveRefreshAllTrustPoints -- Perform an active refresh on all trust points now

REM   /RetrieveRootTrustAnchors  -- Retrieve root trust anchors via HTTPS


REM <Command Parameters>:

REM   DnsCmd <CommandName> /? -- For help info on specific Command


REM In future versions of Windows, Microsoft might remove dnscmd.exe.


REM If you currently use dnscmd.exe to configure and manage the DNS server,

REM Microsoft recommends that you transition to Windows PowerShell.


REM To view a list of commands for DNS server management, type

REM "Get-Command -Module DnsServer" at the Windows PowerShell prompt. Additional

REM information about Windows PowerShell commands for DNS is available at







How to Get Your “App” to

Assume the Privileges of an Administrator


Some computer programs need to run privileged in order to perform their function.  The problem is how to avoid requiring the end user to launch the program with the privileges of the Administrator.  Enter received standard wisdom.  Here’s what you do.  Simply notice that the program is not running as Administrator.  Then, figure out what program is being executed and relaunch it to run as Administrator.  The original, unprivileged instance then quietly exits.







When yours is a simple console application, you don’t have access to the System.Windows.Forms.Application.ExecutablePath() method.  Said method returns the filename of the application’s launchable image.  So other means must be found.  Also, unlike in a Windows forms application, you must cater to command line arguments.  These launch-time inputs are provided via a GUI when you have a window.  The CodeBase() method returns a URL-style reference to the launchable image.  So you must tear off the file:/// prefix.  For good measure, the Unix-style forward slashes in the URL are changed to Microsoft’s patented backslashes.







How to Read and Write a Flat File


A flat file is what database aficionados call a sequential series of similarly-sized records.  In the old days, these records might be called “card images.”  That’s back when punch cards of 80 columns were the common input medium. Practically a stone age technique.  Anyway, flat files are still handy and are the place you put your XML, XAML,C# source code, and logs.  The way you write a flat file is as follows.


using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@”\Users\Public\NameOfFile.txt”))


sw.WriteLine(“Line 1.”);

sw.WriteLine(“Line 2.”);

sw.WriteLine(“Line 3.”);



With the using statement you define a set of statements that enjoy the benefits of an open flat file stream.  These are those statements between the curly braces that follow the using statement.  The using statement itself declares a StreamWriter object reference variable, sw, and initializes it with a newly manufactured object of that class.  The constructor takes the name of the flat file as its argument.  Inside the curly braces you write individual records with the WriteLine method of the StreamWriter object.  Upon exiting the curly braces, the file that StreamWriter opened is automatically closed.  To read those records back, follow this pattern:


using (System.IO.StreamReader sr = new System.IO.StreamReader(@”\Users\Public\NameOfFile.txt”))




string line = sr.ReadLine();

if (line == null)






Inside the curly braces you read individual records and process them.  You continue reading records with the ReadLine method of StreamReader object until the method returns null.  That’s your signal that every record has been returned and you are done reading.  Call break to exit the loop.  Upon exiting the curly braces, the file that StreamReader opened is automatically closed.






How to Discover Whether a File Is In Use by a Different Process


It is highly convenient to know before you touch a file when the file is currently being handled in a different process.  You want to avoid file conflicts.  So, how do you ask the question and get a reasonable answer:  Is this file in use?  Solution:  Available to people who write unmanaged code.  Here we are using the OpenFile method that is provided by Win32.  We demand exclusive use of the file.  When the request is rejected (signaled by a return code that is symbolically represented by HFILE_ERROR), it becomes obvious that exclusive use is not presently available.  Why might that be?  Well, it could be that the file is open in a different process.  So, assume that.  There doesn’t seem to be an equivalent mechanism that is provided in the .Net Framework.  So the next best thing is interoperability in which managed code calls into unmanaged code.  See the section titled:  Interoperability:  Hooking Managed Code to Unmanaged Code.







Read a File to Bits


Sometimes it is beneficial to acquire the bits that are the content of a file rather than rely on more advanced but obscurantist mechanisms that hide the true content and structure of any file.  In this example it is shown how to open a file for reading the bits in the order in which they appear and, for fun, converting those bits to a text stream that encodes the bits with characters taken from the set all uppercase letters, all lowercase letters, the digits, and two special characters.  Each character stands for a specific pattern of six bits.  There are 64 different characters standing for the 64 different bit patterns that are physically possible in six bits.






How to Synchronize PC’s Clock with External Time Server




Where the red rectangle appears you put a symbolic reference to an Internet time server (Network Time Protocol or NTP), e.g.  This command must be called from an elevated command prompt.  That is to say, you must launch CMD so that it runs as Administrator.  It is advisable to stop and restart the Windows Time service following the successful execution of this command, as follows.  You should be sure to perform this procedure on each Domain Controller.  Workstations that are joined to the domain automatically take as their time source the most convenient Domain Controller in their domain.  You should run this procedure (referencing an Internet time server) only on Domain Controllers to save the ecology.  There is no need for every workstation to query the Internet time server when the Domain Controller is perfectly capable of acting as an accurate time source and go-between.  Workstations can run the command by placing the fully-qualified name of the Domain Controller in the red box. A good choice for Internet time server is





Change a File’s Time-of-Last-Reference To Now


To assure a specific file is backed up during your next computer hygiene session you can use the touch utility to mark it as having been changed.  Syntax:  touch <filename>.  If the file exists then the first byte is read and written.  When the file length is zero then the file is opened truncated for writing and nothing is written to it.  When the file does not exist then it is created empty. [touch]





How to Install a Windows Service (aka Daemon)


1.  Start an elevated command prompt.  Suppose you have a shortcut to CMD on your desktop.  Right click it and choose Run as Administrator.

2.  Make your current working directory the place where you keep the installation script.  I call mine Install.cmd.  I put it in the Release folder of the VS solution.

3.  Launch the script.

4.  Microsoft provides a utility program whose name is InstallUtil.  You first remove from the system any previous copy of the service.

5.  Step 4 stops the service process and deletes the service from the Registry.

6.  Step 4 causes InstallUtil to report success in removing the service.  However, the process continues on and on. 

7.  Because of Step 6, we make special arrangements to delay further processing until the process actually disappears.

8.  The touch command creates a temporary file that is necessary because the text editor assumes one exists.

9.  The text editor is invoked to run a text editor script that waits for the service to disappear.

10.         The erase command gets rid of the temporary file of Step 8.

11.         Now we create a folder (aka directory) in which to copy the service executable file.

12.         The old executable, if any, is deleted.

13.         All associated dynamic link library files, if any, are deleted.

14.         The new executable is copied to the directory of Step 11.

15.         InstallUtil is invoked to register the service with Windows.

16.         NET START is invoked to get the service going.



InstallUtil -uninstall WINSVCFILCPY.exe

REM Give Windows a chance to finish uninstalling

REM Windows should not return from uninstalling until uninstalling the service has completed

touch G3u6aX


erase G3u6aX


MKDIR C:\TkKcV6QJm3dP2nU4ps85


ERASE C:\TkKcV6QJm3dP2nU4ps85\*.DLL


COPY *.DLL C:\TkKcV6QJm3dP2nU4ps85

InstallUtil C:\TkKcV6QJm3dP2nU4ps85\WINSVCFILCPY.exe







Avoid the Clunky User Interface That Activates Windows


slmgr.vbs -ipk "xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"


The command slmgr.vbs must be run at a command line prompt that is elevated with Administrator privileges.  Put a shortcut to CMD on your desktop.  Right-click the icon and click Run as administrator.  Then type in slmgr.vbs with the product key.  Eventually you will see a window open stating whether Windows was activated.


Alternative means to persuade Windows to activate itself:  slui 3 or slui 4.


slui 3





slui 4




Get the Build Date of a Managed Code “App”


In C++ there is a compiler-generated pair of variables (__DATE__, __TIME__) that contains the timestamp of the compilation. These variables are called predefined ANSI/ISO C99 and Microsoft C++ implementation preprocessor macros.  No such mechanism appears in C#.  Instead, one is obligated to read the text of the .exe file and find the build timestamp there.  The .exe file is a COFF file.


The Common Object File Format (COFF) is a specification of a format for executable, object code, and shared library computer files used on Unix systems. It was introduced in Unix System V, replaced the previously used a.out format, and formed the basis for extended specifications such as XCOFF and ECOFF, before being largely replaced by ELF, introduced with SVR4. COFF and its variants continue to be used on some Unix-like systems, on Microsoft Windows, in EFI environments and in some embedded development systems.






Any program that you may construct will have dependencies on various runtime methods.  Exposing those dependencies is the job of Depends: The Dependency Walker.  You can discover what’s missing in your runtime environment that will cause your “app” to fail at the worst possible time in the worst possible way.





You Need a Bigger Stack in Managed Code


Suppose your application contains a recursive function and that recursion can occur to a very significant depth.  You run the risk of running out of stack space.  Ordinarily a Stack Overflow exception is a sign of infinite regression or some other logic mishap.  But it can happen that the code is perfect and it requires more stack than the default provision.  What to do?  The simplest thing to do is fork a new thread.  At the fork you specify the size of the required stack.  The initial thread exits and the forked thread continues on.  It is possible to patch the EXE file.  A byte or two in the Portable Executable (PE) or COFF file specifies the stack size of the initial thread.  But making that patch consistently from build to build is problematic.  Better to change the source code.


Unable to Live With Default Settings in Windows?



Immediately after installing Windows you begin trek that ends up reconfiguring many default settings.  Here are a few actions I frequently take.


01.       Use express settings.  Press the Use express settings button on the Settings page.

02.       Enter an invalid e-mail address and a bogus password.

03.       Click the continue without a Microsoft account link.

04.       On the Your account page press the Create a local account button.

05.       Enter Ugen (generic user) under User name.  Enter and re-enter a password.  Enter a password hint.  Click Finish.

06.       Hi

07.       Start > All Apps > Windows System > Control Panel (right-click Control Panel and click Pin to taskbar)

08.       Click Control Panel on taskbar.

09.       Click Network and Internet.

10.       Click Network and Sharing Center.

11.       Click Change Adapter Settings.

12.       Right-click the adapter of choice.

13.       Click Properties.

14.       Scroll down to expose Internet Protocol Version 6 and Internet Protocol Version 4.

15.       Uncheck IPv6.

16.       Highlight IPv4.

17.       Press the Properties button.

18.       Enter computer's IP address, subnet mask, gateway router IP address, two DNS IP addresses.

19.       Click OK.

20.       Click Close.

21.       You can optionally rename the adaptor.

22.       Close Network Connections.

23.       Close Network and Sharing Center.

24.       Click Control Panel on taskbar.

25.       Click Clock, Language, and Region.

26.       Click Date and Time.

27.       Push the Change Time Zone button.

28.       Scroll to the time zone of choice and highlight it.

29.       Click OK.

30.       Click OK to close Date and Time.

31.       In Clock, Language, and Region click Region.

32.       Set Short Date to dd-MMM-yy, Short time to HH:mm, Long time to HH:mm:ss.

33.       Click Apply.

34.       Click OK.

35.       Add C:\Packaged-Software to %PATH%.


37.       Put shortcut to CMD on desktop.

38.       Never power down anything.  Not the hard disks.  And not the display.

39.       Solid color on desktop.

40.       Map drive letters to several shares.

41.       Join the computer to the domain.

42.       Allow the computer to entertain remote access.

43.       Turn off or fiddle with Windows Firewall.




Dirty Little Secrets


Windows will happily let you install and de-install roles and features, “apps” and whatnot.  The dirty little secret is that when you de-install, a lot of detritus gets left behind.  And when you re-install, the detritus guarantees the install you get from fresh is different from the install you get from re-install.  Oh, it’s all happy talk and “everything’s just fine” … until it isn’t.  By Windows, I refer to the operating system proper and its eco-system.  Visual Studio, for example, lets you install Visual Studio, de-install Visual Studio, and re-install Visual Studio.  After that last step, however, not all is right.  Entire folders of header files, for example, go missing.  You do a C++ compilation and somehow the compiler can no longer find parts of your program (headers) that are strictly from runtime libraries.  Solution?  Find a properly constituted installation and manually copy the missing folders to the sick installation.  Alternatively, format your HDD, install a fresh copy of Windows (the operating system), and then install a fresh copy of Visual Studio.


Similarly, when you upgrade Windows Server 2008 to Windows Server 2012 R2, watch out.  The Hyper-V role may not be able to create a virtual switch due to “an internal error.”  Many hours were spent on the phone with the Break/Fix Department trying to sort out why this was so.  It was discovered that PowerShell is able to create a Virtual Switch, but not the button on the Hyper-V control panel.  The problem vanished once Windows Server 2012 R2 was installed to a freshly formatted drive.


Recently, a single HDD (1 of 8) decided to retire.  It was five years old and had put in yeoman service.  It functioned just enough to respond, slowly, to commands.  The Windows 2012 R2 installer depends on perfectly functioning HDDs.  And that’s why the installer got stuck on the screen that reads “Starting to Install.”  And I mean stuck.  It remained static for hours.  The solution was to remove 7 of 8 HDDs leaving the one installed to which the operating system was being loaded.  After the OS was up and running, it was a simple matter of individually installing each HDD in turn watching (in horror) as the file system attempted to recognize various forms of redundancy.  This HDD was “offline.”  That HDD was “foreign.”  “Activate disk” usually got the show on the road.  One mirrored pair recovered nicely.  The other spontaneously broke in two.  In that case I had two nearly identical single volumes rather than the mirrored pair that I wanted.  Fortunately, there was no data loss (unlike in a previous HDD failure case where RAID-5 didn’t recover all the data). The software redundancy implementation is destined to be removed from the operating system because it simply does not work as well as hardware implementations of the same.  The rule is: do not depend on redundancy to protect your data.  Redundancy exists to keep the system limping along until you find a convenient time to replace failing components.  Once components have failed, you may experience data loss.  And that’s where you learn that you must keep current backups. It bears reporting that Windows may be aware that an HDD is failing, but it has neither the time nor the inclination to notify you:  the System Administrator.  Lots of little pop-ups in the lower right corner of the screen to report, for example, the frequent occurrence of network shared folders failing to connect (usually because the authentication credentials have gone stale or the phase of the moon is wrong).  But there is not a word about Disk #5 which is reporting parity errors.


A habit that persists from the days when computers lacked main memory and secondary storage capacity produces cryptic error messages.  These used to be called (by industry insiders) “diagnostic messages.”  What appears on screen is hardly diagnostic.  They mostly boil down to software that refuses to do what you ask of it “because.”  There may be many words but the meaning boils down to “An error occurred.”  The nature and specifics of the error are left to your imagination.  An especially pernicious variety of message marries disparate causalities (either your network connection is down or your configuration is bad, for example).  Well, duh.


When you install a new release of Windows (the operating system), the old Windows folder is renamed Windows.old.  It contains various data that go away because it is too much trouble (or the attorneys say “don’t”) to retain installed applications.  It is a treasure trove of stuff you may want to manually move into the trafficked part of your HDD.  After a while, Windows.old becomes a space-occupying nuisance.  You may want to reclaim that space.  Your natural inclination is to delete the folder.  That would be a simple matter of opening File Explorer, navigating to Windows.old, right-clicking, and selecting Delete.  But, wait.  That produces a blizzard of error messages because the shield of DACLs that formerly protected the Windows folder still applies to Windows.old.  Traditionally this was resolved by pointing CleanMgr at Windows.old.  It contains magic algorithms that know how to persuade files and folders to go away.  Unhappily, this resource has been removed from Windows 2012 R2.  It’s not even in a feature/role called “Windows Desktop Experience.”  I’ve found that taking ownership of everything in Windows.old gets you almost to where you want to be:  free of Windows.old.  However, in my last go round, there persisted a number of files whose names were reported to be “too long” to be deleted.  These files don’t appear on a traditional dir command.  Nor do they appear in File Explorer.  But they are present and you cannot delete them.  Windows has a positive fetish for filenames that are too long.  Here is a case where “filename too long considered harmful” would be an appropriate CACM article.



Negative 54 Error Aborts Attempt to Sync iPhone with Windows


The iPhone "<name-of-device>" cannot be synced.  An unknown error occurred (-54).


Here is the fix.


How to place your device in recovery (DFU-Device Firmware Upgrade) mode:


Follow these steps to place your iOS device into recovery mode.


1.          Should your iOS device already be in recovery mode, you can proceed immediately to step 11.


2.          Disconnect the USB cable from the iPhone, iPad, or iPod touch, but leave the other end of the cable connected to your computer's USB port.


3.          Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider.


4.          Wait for the device to turn off. 


5.          If you cannot turn off the device using the slider, press and hold the Sleep/Wake and Home buttons at the same time.


6.          When the device turns off, release the Sleep/Wake and Home buttons.


7.          While you press and hold the Home button, reconnect the USB cable to the device.


8.          The device should turn on. Note: If you see the battery charge warning, allow the device charge for at least ten minutes to ensure that the battery has some charge, and then start with step 2 again.


9.          Continue to hold the Home button until you see the "Connect to iTunes" screen.


10.       When this screen appears, you can release the Home button.


11.       If necessary, open iTunes. You should see the following “recovery mode" alert: Use iTunes to restore the device.


12.       If you don't see the "Connect to iTunes" screen, try these steps again.


13.       If you see the "Connect to iTunes" screen but the device does not appear in iTunes, see this article and its related links.


Additional Information:


If you have a problem getting into recovery mode then try:  


RecBoot: Easy Way to Put iPhone into Recovery Mode.


Note: When using recovery mode, you can only restore the device.   All user content on the device will be erased, but if you had   previously synced with iTunes on this computer, you can restore from a previous backup. See this article for more information.





Wow. Look how thick the manual is. One hundred and six pages is/isn’t necessary to tell me how to get the clock hands to indicate the correct time. I’ll do it in less than one page. Avoid the GUI. Use Function J.







Hard Links in Windows



cd \Users\Public

deltree HardLinkDrill

mkdir HardLinkDrill

cd HardLinkDrill


echo "Hello!  Semper Fi!" > REALFILE.TXT




findlinks HARDLINK.TXT

findlinks REALFILE.TXT



In Unix, where the concept originated, and in Windows, a hard link is an alias (a different name) for a file.  You can have several hard links to the same file.  You can reference the file by its original name and by any of its hard link names.  You can delete the file by any of the file’s names.  The file remains undeleted until all of its names are gone.  There is a reference count that the file system maintains.  It is decremented each time a hard link is deleted.  Once the file becomes anonymous (i.e. all the names are gone) the file is deleted.


The example, above, creates a directory named HardLinkDrill and creates an original text file REALFILE.TXT.  The mklink command creates a hard link named HARDLINK.TXT.  The two type commands display the contents of the file: the same in both cases.  The SysInternals findlinks command displays the alternative moniker(s) to the one you specify.


In Windows it occurs that file enumeration skips hard links.  One supposes this is to help file backup programs that would otherwise create duplicative backup copies.  Maybe .NET Framework doesn’t deal with hard links because it was deemed to be an unimportant file system feature.  Managed code in C# compiled with Platform Target set to x64 can find C:\Windows\System32\slui.exe with System.IO.File.Exists().  Platform Target set to x86 it cannot.  Apparently this has to do with Windows-on-Windows.  C:\Windows\System32\slui.exe is a hard link to a file named c:\Windows\WinSxS\amd64_microsoft-windows-security-spp-ux_31bf3856ad364e35_6.3.9600.16497_none_4c78319e72ce9d09\slui.exe in a different directory.  One desires a detailed explanation.