Sell your ex-wife’s wedding dress on e-Bay

Yes, you really can sell just about anything on e-Bay. One guy is selling his ex-wife’s wedding dress, which he tells you he originally spent $1,200 on. (Or, as he says, “This dress cost me $1200 that my drunken sot of an ex-father-in-law swore up and down he would pay for but didn’t so I got stuck with the bill”.) The bid’s up to $15,100 as of the time I am writing this blurb. Check out the item at http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=4146756343. If the fact that someone would buy a used wedding dress originally worn by a large Texas woman for over ten times its original price isn’t ridiculous enough, just take a look at the pictures of the dress and the guy’s description of the item… and his updated description… and his yet again updated description… Clearly, lots of people have lots of spare time on their hands (and, as it seems, spare money).

Decoding event log errors with EventID.Net

While at work one day this week, users started complaining about slow access times to a particular application. After confirming that all applicable servers (an application server and a SQL server) were online, and that there were no SQL problems (such as deadlocks), we took a look at the event log, and found an obscure entry:

Type:  Error
Source:  Userenv
Event ID:  1000
Description:  Windows cannot determine the user or computer name. Return value (1722).

Like many good event log messages this told me little about the actual problem. Rather than scratch my head until an answer mysteriously appeared, I went to perhaps the best resource for understanding event log entries: EventID.net (www.eventid.net).

EventID.net provides a searchable index to events, and has extensive information provided by other users that can be invaluable in troubleshooting problems. Using the site is simple: enter the event ID number and the source and click a search button. The site returns a list of possible matches, including descriptions. Find the one that matches your problem the best and click a link to obtain the details.

In my case, a search for “event ID 1000, source Userenv”  brought me to a results page with a few dozen hits. One of those hits matched my event, so I went to the details page. There’s a lot of information here provided from other users, and one common thread in their posts: check your DNS servers and settings.

Sure enough, there were two problems. This server never had its primary DNS server updated some months ago when we changed DNS servers. Further, we also found out that the secondary server, which was previously processing all DNS requests for this server, had stopped running. We changed the primary DNS server and within a minute were operating normally.

The moral of this story: Look at the event log periodically and whenever there is a problem that doesn’t have a clear solution, and when you do, be sure to use resources such as EventID.net to get a complete understanding of the problem and to use other people’s experiences to solve your problem more quickly.

Because newer is not always better, there’s oldversion.com

I used to have piles and piles of CDs with old versions of software. Used to is the operative phrase there; most of those CDs have gone into the garbage over the years. Who ever thought I would need an old copy of Internet Explorer?

If you find yourself needing some old software, check out http://www.oldversion.com. They offer 51 (at the time of writing) different programs, and in most cases different old versions of each one. Want to see AOL Instant Messenger 1.0? They’ve got it. How about America Online 1.0 – a scant 0.3MB? Yup. Adobe Acrobat 2.0? It’s in there. They provide old versions of the most popular instant messenger, file sharing, e-mail, multimedia, and Internet applications.

You may need an old version for compatibility, or testing, or to be nostalgic. Whatever the reason, http://www.oldversion.com is a worthy bookmark.

Renaming files in a subdirectory tree

A coworker had an odd little requirement that they asked me if I could help with. She has image files stored in a directory structure, and she wanted to be able to pull the files out and rename them with the parent directories. Confused? I was, too. Essentially they want a file whose path is \A\01\23\45.tif to be renamed to A012345.tif.

Two steps to solving this. First, I needed a script file that would make a copy of a file and rename it by prepending the names of its parent folders to the filename. Second, I needed a script file which would find every file under a given subdirectory and call the first script file for each file found.

The first script file is a Windows Script Host file, written in VBScript. I name this file sdrename.vbs (as in subdirectory rename). The basic flow is:

  1. Retrieve the full, absolute path to the file from command line arguments.
  2. Determine the root folder (the folder that the script file is executed in).
  3. Extract the filename (only) from the full path of the file.
  4. Extract the names of all subfolders between the root folder and the file.
  5. Strip backslashes out of the subfolders extract (step 4).
  6. Determine the new filename (step 4 + step 3).
  7. Copy the file to the root folder.
  8. Rename the copied file to the new filename (step 6).

Option Explicit
 
'Filenames are required
If WScript.Arguments.Count = 0 Then
  WScript.Echo ">>> Must provide file name!!! <<<"
  WScript.Quit
End If
 
Dim strFile, strRootFolder, strFilename, strNewFilename, objFSO
 
WScript.Echo "*** SUBDIRECTORY FILE RENAMING ***"
WScript.Echo ""
 
strFile = WScript.Arguments(0)
WScript.Echo "Processing:   " & strFile
 
strRootFolder = Left( WScript.ScriptFullName, InStr( WScript.ScriptFullName, WScript.ScriptName ) - 1)
WScript.Echo "Root Folder:  " & strRootFolder
 
strFilename = Mid( strFile, InStrRev( strFile, "\" ) + 1 )
WScript.Echo "Filename:     " & strFilename
 
strNewFilename = Mid( strFile, Len( strRootFolder ) + 1 )
WScript.Echo "Subfolders:   " & strNewFilename
 
strNewFilename = Replace( strNewFilename, "\", "" )
WScript.Echo "New Filename: " & strNewFilename
 
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
 
objFSO.CopyFile strFile, strFilename
WScript.Echo "File copied successfully."
 
objFSO.MoveFile strFilename, strNewFilename
WScript.Echo "File renamed successfully!"
 
WScript.Echo "*** PROCESS COMPLETE ***"

The second script is a simple one-line batch file, which I call renloop.bat (as in rename loop). This calls the shell’s for command to loop through all subdirectories, retrieving the full file name and path for each file that matches the search criteria.

for /r %%i in (%1) do cscript.exe sdrename.vbs "%%i"

To use, copy both script files to the starting directory – the top directory you want to include in the rename. For example, if I wanted to copy and rename all files within c:\mydocs\images\, both files would be copied into this directory. Then, run the following from a command prompt:

renloop *.gif

The result: Every file that matches the search criteria (*.gif) will have the sdrename.vbs script executed against it. Enjoy all your newly created, renamed files!

Updating the system path using Windows Script Host

On a recent business trip, I needed to add the full path to Microsoft Office and Lexis-Nexis CompareRite into the system path. (All workstations were running the French edition of Windows 2000.) Doing this manually – finding the installation path for the applications (since I wasn’t sure if all installations were to the same location on the local hard drives), then manually pasting or typing the paths into the System control panel – was too time-consuming for me, so I wrote a script to do it.

The Windows Script Host (WSH) engine is included with Windows 2000, so I wrote a WSH script using VBScript to do the necessary work:

  1. Read the current system path from the registry.
  2. Read the path to Microsoft Office from the registry.
  3. If the Office path is not already in the system path, append it.
  4. Read the path to CompareRite from the registry.
  5. If the CompareRite path is not already in the system path, append it.
  6. Update the system path in the registry if it changed.

The script follows:


'FILENAME: updpath.vbs

Option Explicit

'Stop at all errors by default
On Error Goto 0

'AddToPath: If sAdd is not in the string sPath, append sAdd to sPath and return the result;
' otherwise, return sPath unchanged.
Function AddToPath ( sAdd, sPath )
If InStr( 1, sPath, sAdd, 1 ) = 0 Then
AddToPath = sPath & ";" & sAdd
WScript.Echo sAdd & " added to path."
Else
AddToPath = sPath
End If
End Function

'DoScript: The main script procedure.
Sub DoScript
Dim WshShell, strPath, strOrigPath, strAppPath
Set WshShell = WScript.CreateObject("WScript.Shell")

On Error Resume Next

'Read the system path. Exit on errors.
strPath = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path")
If Err.Number <> 0 Then Exit Sub
strOrigPath = strPath

'Read the Office path and call AddToPath.
strAppPath = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Office\8.0\BinDirPath")
If Err.Number = 0 Then
strPath = AddToPath(strAppPath, strPath)
End If

'Read the CompareRite path and call AddToPath.
strAppPath = WshShell.RegRead("HKLM\SOFTWARE\LEXIS-NEXIS\Office\7.0\CompareRite\Directory")
If Err.Number = 0 Then
strPath = AddToPath(strAppPath, strPath)
End If

'Update the system path if it's changed.
If strPath <> strOrigPath Then
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path", strPath, "REG_EXPAND_SZ"
If Err.Number <> 0 Then Exit Sub
WScript.Echo "System path updated to:" & vbCrLf & strPath
Else
WScript.Echo "Path not updated - no updates necessary."
End If
End Sub

Call DoScript()

There are two things to consider with this script. First, the changes do not take effect until the user logs off and logs back on (no reboot, just re-logon). Second, the script requires Administrator-level privileges, because the registry key where the system path is stored is read-only to non-administrators. Using the Windows 2000 runas command, we can run the script when logged in as a non-administrator user by running the following line from a command prompt. Just change the user parameter to an administrator-level account, and the path to the actual location of the updpath.vbs file.

runas /profile /user:domain\administrator "wscript.exe \\server\share\updpath.vbs"

Change wscript.exe to cscript.exe if you want the output to appear in a console (command prompt) window.