AutoCopy to update program before running

I’m trying to AutoCopy an update for a program that my device normally wants to run using AutoRun. I see the query of the files on the USB Flash Drive occur from the USBs activity LED, and then my program runs. The only problem is that the AutoCopy isn’t overwriting the previous version. I know that AutoCopy is working as i added some additional support files, and I see them in the file structure, however, it still executes the older version of the program. This tells me that it’s executing the AutoRun program before having the chance to finish AutoCopy, and therefore the original program is not being overwritten.

I’ve tried with AutoCopy, EarlyAutoCopy, and enabled the EarlyAutoCopy in the Wait4FlashDisk registry.

Am I missing something, is there a better approach than simply overwriting an EXE with a newer one?

I’m using the Viola Plus carrier board with WinCE 7.0 version 1.9. The USB port is the native USB on the Viola Board as well.

Thanks in advance,

Matt

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello Matt,

Thank you for reaching out with your question. It sounds like you’re encountering a timing issue where the AutoCopy process isn’t completing before AutoRun executes your program on the Viola Plus carrier board with WinCE 7.0.

Here are some steps you can take to address this:

  1. Verify AutoCopy Completion: Ensure that the AutoCopy process is fully completed before AutoRun is triggered. You might need to adjust the timing or sequence of operations in your setup to achieve this.

  2. Check Registry Settings: Double-check the Wait4FlashDisk registry setting. This setting should delay the AutoRun until the flash disk is ready, allowing AutoCopy to complete. Make sure it’s configured correctly.

  3. File Access: Ensure that the files you want to overwrite are not locked or in use by another process. This can prevent them from being updated. Check the file attributes and ensure no other applications are accessing them during the update.

  4. Minimal Setup Testing: Test the AutoCopy and AutoRun process with only the essential files on the USB drive. This can help determine if additional files or processes are interfering with the update.

  5. Alternative Update Method: If the issue persists, consider using a script to ensure the copy operation is complete before launching the application. This can provide more control over the update process.

By following these steps, you should be able to ensure that the updated version of your program runs correctly. If you continue to experience issues, further investigation into your specific configuration may be necessary.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

https://community.toradex.com/tag/wince

Windows Embedded Compact 7 fails to copy Autocopy folder from USB Drive.

Have you tried delaying the start of your application by using a batch file or a separate small launcher app?

I have not. I was under the impression that WEC7 didn’t support batch files, but I may give the launcher program a go.

File Types

The Launcher.exe is able to handle Files in the AutoRun folder with the following extensions:

  • .exe (Executable Files)
  • .lnk (Shortcut Files)
  • .bat (Batch Files) only supported on Tegra BSP V2.0beta4 and later

Batch Files

To launch a .bat (Batch File) on other BSPs create a .lnk (shortcut) file with contents as below:

48#"\windows\cmd.exe" /c "\directory\yourBatch.bat"

Notes:

  • 48# is is the total length of the shortcut string including quotes, but not including the 3 characters: 48#.

  • For more information about shortcuts in WinCE, check this link: Shortcut

I am getting places with the batch file. I had it do a fixed delay, but now i’d honestly prefer that it not execute the main program until the updating USB drive is detected as removed. This is nice as it also offers a solution to keep the program from running in case i ever need to do anything in the background before committing the watchdog or opening resources from within the main program

this feels close, but it keeps running regardless of if USB HD is present or not

@echo off
echo Checking for Updates…
:wait_for_directory
if exist “\USB HD\”(
echo USB Drive exists… Waiting…
ping 127.0.0.1 -n 3 >nul
goto wait_for_directory
)
echo Launching Program…
start \FlashDisk\Program\Program.exe

I’d rather use another logic.
Create a \FlashDisk\noupd.flg file, which will indicate that no update process is running and app can be launched. Then, when the update batch file starts, simply remove it at the beginning and recreate it once the update is complete."

@echo off
:wait_for_upd
ping -d 127.0.0.1 -n 3
if not exist “\FlashDisk\noupd.flg” goto wait_for_upd
echo Launching Program
start \FlashDisk\Program\Program.exe
exit

ultimately, i ended up creating a quick and simple launcher program to accomplish everything, but i also did go the route of removing my old shortcut using the bat file and shortcut to call that.

thanks for the help!