Home Web Server: DynDNS Updater portability

DynDNS Updater portability
Home Web Server Uniform Server 3.5-Apollo.

DynDNS Updater is not truly portable; I like this software hence am prepared to overlook this one minor issue.

It does write to the registry, it’s a shame because it only writes a version number and path to the ini file. Neither is really required does not affect portability, just leaves this dross behind.

If you are a purest I provide a solution for XP Home (only because I have tested on this platform)

This page is really about integrating the Updater to make the whole server experience a little less prone to mouse clicking and hunt the files.

Ease of use

You have your server working, that’s the hard work over with; this is more of a leisurely stroll to enhance usability.

You can pick and mix the ideas from this section to best suit your own needs. I will just ramble on in no particular order of significance.

Updater Start and Stop

I like to have all my control files located in the Uniform Server folder, makes them easier to find. I need to start and stop the Updater hence straightaway create two batch files as follows and place them in the "Uniform Server" folder:

updater_start.bat

@echo off
start dyndns_updater\DynDNS.exe
:pause

 

updater_stop.bat

@echo off
udrive\home\admin\program\pskill.exe DynDNS.exe c
:pause

They work, but hang on a moment we already have a start and stop file. Reduce the clutter in "Uniform Server" folder by adding the above lines to these files. Yep, hack “Server_Start” and “Stop” bat files


Server_Start.bat

Open Server_Start.bat and add the line shown in bold
I have show only part of this file.

Server_Start.bat

if errorlevel 2 goto :PAUSE
if not errorlevel 1 goto :STARTED
start dyndns_updater\DynDNS.exe
set Disk=%1

 

Stop.bat

Open Stop.bat and add the line shown in bold
I have show only part of this file.

Stop.bat

@echo off udrive\home\admin\program\pskill.exe Apache.exe c
udrive\home\admin\program\pskill.exe DynDNS.exe c


Note: When DynDNS.exe stops the tray Icon is still visible, mouseover this Icon and it will disappear. I have been unable to find a method of refreshing the System Tray Icons using a batch file. Its not a problem just does not look professional.

Top

Registry Dross

Finally I would like to address the registry dross problem. This section focuses on reading and editing Windows XP registry using REG.EXE which is a native command.

A quick overview of what REGEDIT can do is shown below:

Adding items REGEDIT /S fred.REG The /S switch is optional (skips message dialogs before/after the import) in this example fred is the name of the file to import.
Removing entries [-HKEY_CURRENT_USER\MyTree] To remove an entire "tree" add a minus sign before the tree name.

For example this removes the entire tree "MyTree" from the registry.

  [HKEY_CURRENT_USER\MyTree2]
" ValueToBeRemoved"=-
To remove an individual item from the registry, place the minus sign after the equal sign.

For example this removes the individual value "ValueToBeRemoved" from "MyTree2".

Reading (exporting) REGEDIT /E fred2.REG "HKEY_XXXX\Some Key " The /E switch can be used to read (export) a registry key:

Writes the registry key "HKEY_XXXX\Some Key" and its sub-keys to a file named fred2.REG The resulting text (fred2.REG) file will contain entries in the format "key"="value". Adding and Removing items

Adding and Removing items

Adding and removing registry items requires a temporary file *.REG (note the file extension REG) containing the elements to be added (imported) and or removed. The file is imported into the registry using the following command REGEDIT /s run from a command prompt:

Temporary file

The temporary file *.REG must have the following syntax (format):

REGEDIT4 All registry scripts must start with REGEDIT4 (backwards compatibility)
  This line must be blank
[-HKEY_CURRENT_USER\MyTree] Keys to change (import)
  Optional line between each key (makes it easier to read)
[-HKEY_CURRENT_USER\MyTree] Final key to change (import)
  The last line of a reg file must be blank.

You can also execute a *.reg file by double clicking it (the file extension .reg is associated with regedit).

REG files can also be run from a batch file see next section.

Top

REG Examples

I am sure you are aware editing the registry can be very dangerous because of this deters most people. A bit of confidence building is in order, first lets locate the key we wish to remove by running regedit. (Assumes you have installed the Updater)

Start > click Run > type regedit in the text box and click OK

This opens the edit window, starting from the top left, expand the folder tree by clicking on the plus to the left of these folders:

  • HKEY_CURRENT_USER
  • Software
  • Kana Solution
  • You will see this folder: DynDNS Updater
  • Right click on this folder (DynDNS Updater) and select Copy Key Name
  • (This saves the complete path in the past buffer hence you can past it into a document)
  • Complete path:
  • HKEY_CURRENT_USER\Software\Kana Solution\DynDNS Updater

Click on the folder DynDNS Updater and note the parameters set in the right window. You should see the ini path and version number.

You could use this edit window to delete the registry key. However the above shows how to easily obtain the full path to a known key and paste the result into a batch file this prevents typing errors.

Top

REG Example - 1

This example shows how to read a registry key using a batch file. First create a new folder (name it whatever you like) then create this batch file and save it to your new empty folder.

test1.bat

@ECHO OFF
cls
echo ========= TEST1.BAT READ KEY ==========
echo Creating file fred.reg and reading key
:: Read registry
START /W REGEDIT /E test_result.REG "HKEY_CURRENT_USER\Software\Kana Solution\DynDNS Updater"
pause

Run test1.bat by double clicking on it, when run you will see a new file named test_result.reg. Open this file and you will see something similar to the following:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Kana Solution\DynDNS Updater]
" Version"="3.1.0 (Build 15)"
" IniFile"="G:\\Uniform Server\\dyndns_updater\\DynDNS.ini"

The important line in the above batch file is:

START /W REGEDIT /E test_result.REG "HKEY_CURRENT_USER\Software\Kana Solution\DynDNS Updater"

Breaking it down:

START /W --- Runs the program REGEDIT and the /w instructs the batch file to wait until the program REGEDIT closes before continuing.

REGEDIT /E --- REGEDIT is the program to be run, the /E instructs it to run in export (read) mode.

test_result.REG --- This is the file where the export date will be written, if it does not exist it is created.

"HKEY_CURRENT_USER\Software\Kana Solution\DynDNS Updater" --- This is the key to be exported and must be contained in quotes.

Top

REG Example - 2

This example is a little more interesting it shows how to dynamically create a temporary file using a batch file. This new file will be used for deleting the above registry key. Note: At this stage it will not delete the key.

test2.bat

@ECHO OFF
cls
echo ========= TEST2.BAT Create Temp File ==========
echo Creating a temp file of the correct format
echo File will be named reg_delete.reg

:: Create a temporary REG file
> reg_delete.reg ECHO REGEDIT4
>> reg_delete.reg ECHO.
>> reg_delete.reg ECHO [-HKEY_CURRENT_USER\Software\Kana Solution]
>> reg_delete.reg ECHO.

pause

Run test2.bat by double clicking on it, when run you will see a new file named test_result.reg. Open this file and you will see something similar to the following:

REGEDIT4

[-HKEY_CURRENT_USER\Software\Kana Solution]

The batch file uses > and >> combined with ECHO breaking down the first two lines will explain what they do:

 >reg_delete.reg ECHO REGEDIT4 

The ">" instructs a batch file what follows will be directed to the named file and overwrite it's content. If the file does not exist create it. ECHO Instructs the batch file to output what follows until it reaches end of line. (Writes REGEDIT4 to the file reg_delete.reg)

 >> reg_delete.reg ECHO.

The ">>" instructs a batch file what follows will be appended to the named file.
ECHO. Instructs the batch file to output a blank line. (Writes a blank line to the end of file reg_delete.reg)

ECHO with no dot. Instructs the batch file to output what follows until it reaches end of line. (Writes another line to the end of a file).

That covers every thing we need to zap that registry key.

Top

REG Example - 3

To remove the registry key combine example 1 and 2 as follows:

test3.bat

@ECHO OFF
cls
echo ========= TEST3.BAT Zap registry key ==========
echo Creating a temp file of the correct format
echo File will be named reg_delete.reg

:: Create a temporary REG file
> reg_delete.reg ECHO REGEDIT4
>> reg_delete.reg ECHO.
>> reg_delete.reg ECHO [-HKEY_CURRENT_USER\Software\Kana Solution]
>> reg_delete.reg ECHO.

Import file to registry

echo Zapping Key
START /W REGEDIT /S reg_delete.reg

echo Finished

pause

The line START /W REGEDIT /S reg_delete.reg runs REGEDIT in silent mode, and imports the file removing the key. Note: Delete file test_result.REG now run test1.bat the file will no longer be created because there is nothing to export. It will only be re-created if there is data to write.

Essentially that is the solution to the portability problem; with a few minor changes we can integrate that into our design.

Top

REG Final

Example 3 leaves its own dross behind in the form of that temporary file, easily resolved by deleting it. For user feedback most of my test files contain echo statements only required when using the pause command. The cleaned file is shown below, save this to folder dyndns_updater:

remove_key.bat
@ECHO OFF
cls
:: Removes Updater registry key. Tested on XP home

:: Create a temporary REG file named reg_delete.reg
:: Write correctly formatted data to file
> reg_delete.reg ECHO REGEDIT4
>> reg_delete.reg ECHO.
>> reg_delete.reg ECHO [-HKEY_CURRENT_USER\Software\Kana Solution]
>> reg_delete.reg ECHO.

:: Import file to registry removes registry Key
START /W REGEDIT /S reg_delete.reg

:: Clean up own dross
del reg_delete.reg

This batch file will be run from "Stop.bat" file which needs modifying as follows:

Open Stop.bat and add the line shown in bold I have show only part of this file.

Stop.bat
@echo off
udrive\home\admin\program\pskill.exe Apache.exe c
udrive\home\admin\program\pskill.exe DynDNS.exe c
call dyndns_updater\remove_key.bat

Top

Conclusion

If you do not like the idea of messing with the registry there is no need to use remove_key.bat it’s just, nicety. However Uniform Server with Updater and the modified batch files allow you to run a portable server on a USB memory stick. Just copy the folder “Uniform Server” and all its content, run on a similar system and your IP address will be update at DynDNS. Use your domain name to access the servers no need to worry about what IP the host system uses.

Top


  Ric