All Forums
 Microsoft Windows CE
 CE Sample Applications and Utilities
 eVC - ADSCopy.exe (persisting files/registrations)
 Forum Locked  Topic Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

ctacke

877 Posts

Posted - 20 May 2002 :  16:30:58  Show Profile  Email Poster
ADSCopy.exe: Persisting files and COM registrations

The Windows CE file system is RAM-based. When your device loses power, information that has been added to the file system since the last boot is lost. This often has the undesired effect of erasing files, applications and COM library registrations.

Many ADS systems can be configured with back up power so that the system never loses power (this is the method most PDAs use). Another solution is to write information the FlashFX disk or external storage. However, your application may require that certain files, settings or drivers be installed before it can execute successfully.

ADSCopy.exe is a tool that helps restore a device to an application-specific state even after a power loss or hard reset, giving the effect of file and partial registry persistence. No battery backup of your system is required.

Key APIs Used


CreateDialog
CreateThread
GetModuleFileName
CreateProcess
CreateDirectory
CopyFile
RegOpenKeyEx
RegQueryValueEx
RegCloseKey
CreateMutex
_wfopen
_fgetts
fclose

Lines of Code: 422

Usage

The ADSCopy solution requires two components: ADCopy.exe and ADSCopy.inf.

When ADSCopy.exe runs, it looks for a folder named \ADSCopy in the same directory from which ADSCopy.exe was run. It then searches that folder for for ADSCopy.inf, which it parses as an action list. ADSCopy.inf contains the names of files to copy (which must also reside in the same\ADSCopy folder as ADSCopy.inf), destination paths for those files, and/or optional action flags to register or run the file.

At runtime, ADSCopy checks to ensure that only one instance is running.

ADSCopy will only run on first boot (i.e. only after a hard reset). A soft reset increments the BootCount beyond 1, which ADSCopy checks.
The available flags are:
  • -r: Register the file by calling DllRegisterServer

  • -e: Execute (run) the file and continue processing ADSCopy.inf

  • -x: Execute and wait. Executes the named file a waits infinitely for the spawned process to complete before continuing.


Constraints and Requirements
  • ADSCopy must be an ANSI text file.

  • Each file name must be on its own line, with a new line (\n) terminator

  • Filenames and paths must be enclosed in single quotes

  • Filenames and paths containing spaces must also be enclosed in double quotes

Useful Companion Tools

ADSAlloc can be used to set a predetermined memory allocation (system versus file) at startup.
ADSReg can be used to parge a REG file and apply desired registry changes at boot.
Restart.exe is already in your device's Windows directory and can be used to reboot the system if needed (i.e. after driver installation).

Example

We have an application (MyApp.exe) that we want to persist after power loss. MyApp.exe requires a COM library (MyLib.DLL) to be present and registered and a database (MyData.cdb) in order to function properly. We want MyApp.exe to run immediately after power up without user intervention. Additionally, we want to run ADSAlloc.exe from the 'FlashFX Disk' directory on startup with a command-line parameter of 0x800.

To change these settings and boot the application on startup, do the following:
  1. Place ADSCopy.exe in the \FlashFX Disk\Startup folder. This will cause ADSCopy to run on power up.

  2. Copy MyApp.exe, MyLib.DLL and MyData.cdb to the \FlashFX Disk\Startup\ADSCopy folder.

  3. Copy ADSAlloc.exe to the \FlashFX Disk folder

  4. Create an ADSCopy.inf text file and place it in the \FlashFX Disk\Startup\ADSCopy folder. It should contain the following:
    'MyData.cdb' '\Program Files\MyApp'
    'MyLib.dll' '\Windows'
    'MyApp.exe' '\Program Files\MyApp'
    '\Windows\MyLib.dll' -r
    '"\FlashFX Disk\ADSAlloc.exe" 0x800' -x
    '\Program Files\MyApp\MyApp.exe' -e

On startup the following will occur:
  1. ADSCopy.exe will execute

  2. MyData.cdb will be copied from \FlashFX Disk\ADSCopy to \Program Files\MyApp

  3. MyLib.dll will be copied from \FlashFX Disk\ADSCopy to \Windows

  4. MyApp.exe will be copied from \FlashFX Disk\ADSCopy to \Program Files\MyApp

  5. MyLib.dll will be registered (-r flag)

  6. ADSAlloc.exe will be exectuted from the 'FlashFX Disk' directory with 0x800 as a command line parameter.
    Parsing will wait until ADSAlloc completes (-x flag)

  7. MyApp.exe will be executed (-e flag)


It's Open-Source Code: Change It!

This sample code is provided as an example of ways you can create your own application launcher. If you would like to share the improvements or corrections you make, email them to us. We'll be glad to post them.

Usage Examples

See Topic 1364 for additional, real-world applications of ADSCopy.

Source Download

Rev A (20k zip) 11-Sep-2003




Modified July 9, 2002 - ctacke
Modified July 19, 2002 - ctacke
Modified July 22, 2002 - ctacke: rev 4 feature update
Modified July 26, 2002 - ctacke: rev 5 feature update
Modified August 16, 2002 - ctacke: rev 6 feature update
Modified March 31, 2003 - ctacke: added key APIs, LOC
Modified June 13, 2003 - ctacke: rev 7 feature update
Modified July 18, 2003 - ctacke: rev 8 feature update
Modified August 11, 2003 - akidder: add notes about modifications
Modified Sept 11, 2003 - ctacke: rev 9 bug fix
Modified Feb 17, 2004 - akidder: update introduction
Modified Feb 24, 2004 - akidder: add link to examples
Modified Sep 13, 2004 - ctacke: rev A feature update

ctacke

877 Posts

Posted - 09 Jul 2002 :  17:06:41  Show Profile  Email Poster
Feature Update

We've modified ADSCopy to allow command for waiting for executed process to finish. The execution is now somewhat altered. Now, any line with a flag will *only* act upon the flag - file names with a flag will *not* be automatically copied. To copy and then run, you must use two separate lines in the INF file.

New Flag Definitions
any line with a flag will not get copied (see above)

  • -r : Register. Remains the same, this will call DllRegisterServer on the file

  • -e : Execute and continue. Simply executes the named file and continues processing

  • -x : Execute and wait. Executes the named file a waits infinitely for the spawned process to complete before continuing.


Go to Top of Page

ctacke

877 Posts

Posted - 19 Jul 2002 :  13:29:01  Show Profile  Email Poster
Feature Update

We've modified ADSCopy to accept running files with command-line parameters.
We've also modified it to no longer run always from FlashFX Disk. Instead the source directory for files to be copied is now {exe location}\ADSCopy. This allows ADSCopy to be used effectively from FlashFX or ATA card.
Go to Top of Page

ctacke

877 Posts

Posted - 22 Jul 2002 :  17:57:29  Show Profile  Email Poster
Rev 4 Feature Update and Fix

We've modified ADSCopy to allow the source file for the run options (-e and -x) to have a space in the path as well as having command line parameters.

We've also made a string parsing fix.

-----------------
Chris Tacke, eMVP
Applied Data Support
Go to Top of Page

ctacke

877 Posts

Posted - 26 Jul 2002 :  16:59:21  Show Profile  Email Poster
Rev 5 Feature Update: Creates Destination Folder, INF File in ASCII

Previous versions would fail if a file copy's destination directory did not exist. Version 5 now creates directories as needed.

Note: The INF file requirement for Unicode format has been eliminated. The INF file must now be in standard ANSI format

-----------------
Chris Tacke, eMVP
Applied Data Support
Go to Top of Page

ctacke

877 Posts

Posted - 16 Aug 2002 :  09:38:57  Show Profile  Email Poster
Rev 6 Feature Updates: Single instance, only on first boot

ADSCopy now disallows multiple copies to run simultaneously.

ADSCopy now checks the BootCount when it starts and only processes when BootCount = 1. This means that ADSCopy will no longer run after a soft-reset or when restart.exe is run.

-----------------
Chris Tacke, eMVP
Applied Data Support
Go to Top of Page

superiorcontrols

25 Posts

Posted - 24 Feb 2003 :  11:15:50  Show Profile  Email Poster
WARNING

If you leave a extra blank line in your ADSCOPY.INF then the line above will be executed a second time. In the example given above, MYAPP.exe is started twice.
Go to Top of Page

tbronez

17 Posts

Posted - 14 Mar 2003 :  13:06:36  Show Profile  Email Poster
Can this utility be used to either (A) create folders or (B) launch batch files?

I need the capability to create specific subfolders in \Windows and then copy files from FlashFX into those subfolders. I've got a batch file which does the whole process just fine. Can I handle the folder creation process directly in ADSCopy or launch the batch file via ADSCopy? Or is there another way to handle this?
Go to Top of Page

ctacke

877 Posts

Posted - 15 Mar 2003 :  18:50:51  Show Profile  Email Poster
ADSCopy will generate any folders that it needs to to place the target file. It won't however just create a folder since every line of the INF file must have a source and target.

As to launching an app, it simply calls CreateProcess on the target, so if you batch file works with CreateProcess, then sure.
Go to Top of Page

mmp

31 Posts

Posted - 10 Apr 2003 :  16:28:17  Show Profile  Email Poster
Hello All,

I am having some problems with the ADSCopy.exe utility. I am trying to copy a .DLL file to the \Windows folder and then execute an application. The problem is that ADSCopy.exe does indeed copy the .DLL to \Windows but unfortunately it does not execute the application that I specified.

Pasted below is my ADSCopy.inf file which is of course copied in the ADSCopy folder located in \FlashFX Disk\Startup\

'Can.dll' '\Windows'
'FlexosealPro.exe' '\Program Files\FlexosealPro'
'\Program Files\FlexosealPro\FlexosealPro.exe' -e

Note: Even though the ADSCopy.cpp file says that the .inf file should be UNICODE it does not seem to work at all if I use a UNICODE format (no action takes place, either copying or executing.) Thus, my .inf file is ANSI plain text. Furthermore, it does have a "\n" after the last line.

"FlexosealPro.exe" is located in \FlashFX Disk\Startup\ADSCopy (same path as the .inf file and the .dll file) and "ADSCopy.exe" is located in \FlashFX Disk\Startup

When I start the system, the following actions occur:

1) The Can.dll file is copied to \Windows
2) The FlexosealPro.exe application is copied to \Program Files\FlexosealPro
3) FlexosealPro.exe located in \Program Files\FlexosealPro does not get executed.

FlexosealPro.exe is approximately 700k in size (just in case there is some sort of size limitation which I don't think it's the case.)

Also, it is worth noting that the application does not automatically terminate if some error occurs (it always displays some sort of messages and waits for an OK button to be pressed.) Lastly, the application is not somehow hidden by the desktop (as some posts mentioned that the desktop may 'cover' the actual application this way preventing the app from being in foreground.) Just to make sure, I also used a Remote Process Viewer to see if somehow the application is executed, but it seems as though indeed, the application is not executed at all.

Does anybody have any hints?

Thanks in advance,
Marius


Go to Top of Page

mmp

31 Posts

Posted - 10 Apr 2003 :  16:36:13  Show Profile  Email Poster
ignore my prev. post.

I solved the problem by using double quotes in conjunction with the single quotes since I had spaces in the path names.

To the ADS Team:

What threw me off was the example given in this topic (first post by ctacke.)

'MyData.cdb' '\Program Files\MyApp'
'MyLib.dll' '\Windows''MyApp.exe'
'\Program Files\MyApp''\Windows\MyLib.dll' -r'
"\FlashFX Disk\ADSAlloc.exe" 0x800' -x
'\Program Files\MyApp\MyApp.exe' -e

Note that the last line implies the fact that MyApp.exe can be executed using single quotes even if there are spaces in the path name. Quickly scanning the example, made me think that the double quotes are only necessary when a parameter is used (such as 0x800) with the application that needs to be executed.

Thus, I think there is a small mistake with the example provided showing that applications located in paths that have spaces can be executed by using only single quotes.

Marius


Edited by - mmp on 11 Apr 2003 10:48:56
Go to Top of Page

ctacke

877 Posts

Posted - 13 Jun 2003 :  11:25:27  Show Profile  Email Poster
Rev 7 Feature Update: Copy in Background

Previous versions of ADSCopy ran all copying and processing in the primary thread. For long/large copy operations, especially when used at device startup, this made device response sluggish.

We've modified ADSCopy to spawn a worker thread to do all copy operations as well as present a dialog letting the user know files are being copied.

Go to Top of Page

robertbowen

10 Posts

Posted - 21 Jun 2003 :  10:06:35  Show Profile  Email Poster
[Problem] "Cannot copy files to the FlashFx Disk."
=================================================

I've been succesfull at using ADSCopy.exe as described above.
Today, I needed to replace myApplication.exe file which is stored on the FlashFx Disk\Startuo\ADSCopy folder and for some reason the system hangs when I try to copy a new file to this directory.

I don't remember setting any dip switches prior to copying files to Flash?

What am I missing here?
Go to Top of Page

ctacke

877 Posts

Posted - 18 Jul 2003 :  18:09:03  Show Profile  Email Poster
Rev 8 Feature Updates: Wildcards, blank lines

Previous versions of ADSCopy had problems if there were blank lines in the INF file. This has been corrected.

You can now use comment lines in your INF file. Any line beginning with a semicolon (;) character will be ignored.

Directory wildcards are now accepted for source files. This means that you can copy long lists of files without explicitly naming each source file.

Example
Assume you have a subdirectory in your source tree with files you want to copy. The tree would look like this:

..ADSCopy.exe
..ADSCopy
..ADSCopyADSCopy.inf
..ADSCopysourcedir
..ADSCopysourcedirsrc1.txt
..ADSCopysourcedirsrc2.txt
..ADSCopysourcedirsrc3.txt


In a tree it would look like this:


ADSCopy.exe
ADSCopy
   |
   ------ ADSCopy.inf
          sourcedir
               |
               ------ src1.txt
                      src2.txt
                      src3.txt


The following INF file line would copy the entire subdirectory to the Target directory:

; copy all files in sourcedir directory
; to Target directory
'sourcedir*' 'Target'

Go to Top of Page

Patrick

34 Posts

Posted - 23 Jul 2003 :  15:33:12  Show Profile  Email Poster
What about the situation where the board boot count has climbed and can't be reset? I think it may be related to the persistent registry, because if I erase it, copy starts working again. Any idea what might make it climb? We're totally cutting power to shut our system down.
-Patrick
Go to Top of Page

ctacke

877 Posts

Posted - 23 Jul 2003 :  15:37:11  Show Profile  Email Poster
Yes, the persistent registry stores this and can cause bugs with Rev 7 and earlier. I forgot to mention in the Rev 8 update that I also worked around this problem (by storing a count to a RAM based file that gets erased on power down).
Go to Top of Page

Patrick

34 Posts

Posted - 23 Jul 2003 :  15:48:54  Show Profile  Email Poster
Works like a charm, thanks.
-Patrick
Go to Top of Page

colled

5 Posts

Posted - 04 Aug 2003 :  11:26:56  Show Profile  Email Poster
I'm am using ADSCopy to copy and register some dll's needed by a pcmcia card that is plugged in permanently to the Bitsy Plus. The problem is that the Bitsy checks the pcmcia socket before the dlls have been copied and registered, and thus fails to initialise the card correctly. The only way round this seems to be to remove the card and reinsert it, which is not an option for us as the bitsy is not going to be accessible in use. Please help !

Go to Top of Page

ctacke

877 Posts

Posted - 04 Aug 2003 :  12:02:00  Show Profile  Email Poster
In this type of situation it is probably best to have your driver and settings built into a custom Windows CE image. Our sales staff can help you with this.
Go to Top of Page

colled

5 Posts

Posted - 07 Aug 2003 :  04:19:33  Show Profile  Email Poster
Thanks, we have contacted your sales department. In the meantime, is there a way of re-initialising the pcmcia slot from software after the dll's have been loaded using ADSCopy (i.e. the equivalent of doing a manual reinsert of the card) as this should fix our problem ? I was hoping there might be a o/s api call to do this or by using one of the digital ports.

thanks.
Go to Top of Page

jmedding

1 Posts

Posted - 09 Aug 2003 :  11:37:36  Show Profile  Email Poster
I've found, I believe a couple of bugs in the directory wildcard copy feature. First, I believe that your post shows '\sourcedir\*' when it should show 'sourcedir\*'

Second, ADSCopy appears to not be able to copy some file types. I wanted to copy ".url" files to the \windows\favorites directory. ADSCopy would indicate that it had copied the files (i.e. it didn't report any errors), but, in fact, no files were copied. After playing with it, I found that the only way I can get my .url files to copy is to list each out individually.
Go to Top of Page

akidder

1519 Posts

Posted - 11 Aug 2003 :  16:14:06  Show Profile  Email Poster
Thanks for the notes. This is sample code, so run with it for your own application needs! Feel free to send us what you find. We'll be glad to share it on this forum.
Go to Top of Page

akidder

1519 Posts

Posted - 12 Aug 2003 :  14:44:14  Show Profile  Email Poster
colled: I've posted some notes about simulating re-insertion of a PCMCIA or CF card at topic 1075.
Go to Top of Page

ctacke

877 Posts

Posted - 11 Sep 2003 :  15:29:13  Show Profile  Email Poster
Rev 9: Registration Bug Fix

We've found and fixed a bug with the automatic registration (-r) flag implementation. The fix is included in the Revision 9 source and binary above.
Go to Top of Page

kurtwl

28 Posts

Posted - 27 May 2004 :  11:31:17  Show Profile  Email Poster
It seems that ADSCopy.exe, once run (from 'FlashFX Disk\Startup') is then copied into rom.

Is this true when run from 'Storage Card\Startup' aswell?

What other files does this happen to?
ADSReg etc?

As with ADSLoad.bmp, how can they be gotten out of rom if required.

Would it be possible to have a list of items that are persisted, (including things from the registry if the Persistent Registry is in the CE build)?
Go to Top of Page

ctacke

877 Posts

Posted - 27 May 2004 :  11:41:36  Show Profile  Email Poster
I'm not certain what's you're seeing - once the CE image is built here, files cannot be "added" at runtime, so ADSCopy.exe isn't doing so. (ADSLOAD.BMP/REG/HWT are actually in flash outside of the image area and are processed by the boot loader, not CE itself).

As for persistence, other than the registry, everything not in the FlashFX Disk folder is lost when power is lost.
Go to Top of Page

kurtwl

28 Posts

Posted - 27 May 2004 :  11:44:32  Show Profile  Email Poster
My Bad. I had renamed ADSCopy.exe, thinking that that was explicitly run by something magical, but it was just an exe getting run because it was in 'Startup'.
Go to Top of Page

ctacke

877 Posts

Posted - 13 Sep 2004 :  14:21:23  Show Profile  Email Poster
#Rev A

Rev A Feature Update: Relative Paths

We've uploaded revision A. This revision supports relative and absolute paths, plus has some bug fixes and better internal error checking.
Go to Top of Page

tpannone

6 Posts

Posted - 01 Dec 2009 :  11:08:16  Show Profile  Email Poster
I'm attempting to use ADSCopyexe (Rev A 11-Sep-2003) to place a shortcut link on the desktop of my AGX (CE Build 4.20.12 Pro). My ADSCopy.ini file, which is located in the \FlashFX Disk\Startup\ADSCopy folder, contains the line 'RcsDisplay.lnk' '\Windows\Desktop' . The .lnk file is also in the ...\ADSCopy folder.

When I boot the AGX, a window saying "Copying files, please wait..." appears on the desktop. THe window never goes away and the shortcut never appears on the desktop.

What could be the problem?

tpannone
Go to Top of Page

twhite

133 Posts

Posted - 03 Dec 2009 :  13:54:38  Show Profile  Email Poster
tpannone,

Possibly this could be as easy as checking the name of the config file for ADSCopy. It should be ADSCopy.inf, not .ini. Could you please check that before moving forward?
Go to Top of Page

twhite

133 Posts

Posted - 03 Dec 2009 :  17:09:23  Show Profile  Email Poster
tpannone,

In the original description of the ADSCopy operation, there is a very important operational section to note. It is, "When ADSCopy.exe runs, it looks for a folder named \ADSCopy in the same directory from which ADSCopy.exe was run. It then searches that folder for for ADSCopy.inf, which it parses as an action list. ADSCopy.inf contains the names of files to copy (which must also reside in the same\ADSCopy folder as ADSCopy.inf), destination paths for those files, and/or optional action flags to register or run the file.
"
Please be sure to note your folder and subfolder locations.

twhite
Go to Top of Page
  Topic  
 Forum Locked  Topic Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.08 seconds. Snitz Forums 2000