I would like to know if this is possible and if so how:
I have an application in a USB stick in Autocopy folder. I would like to insert the USB stick in Toradex module and it will auto copy itself and after that, it will run Autorun (or by any other means it will run an executable to do some work after copying)
Is Autorun in the USB executed 1st or Autocopy executed 1st? Or they run simultaneously?
Basically AutoRun is executed after AutoCopy. But this only applies on folders that are already on the storage device while booting. The system does not trigger a second run of the scripts after AutoCopy is executed.
I assume you want to start the executable from the target where it is copied to by AutoCopy. In that case you could write a batch script which will be triggered by AutoRun which then executes the binary from the target location. Assuming you have the AutoRun and AutoCopy folders on a USB device, the structure would look like the following:
USB HD
├───AutoCopy
│ └───FlashDisk
│ MyApplication.exe
│ runMyApplication.bat
│
└───AutoRun
runMyApplicationBatch.lnk
The .lnk file is necessarily because with older launchers, you can not run .bat files directly. After AutoCopy copied the files to the device, the *.lnk file will trigger the *.bat file. In the batch file you actually execute MyApplication.exe with referencing the fullpath of the binary (i.e. \FlashDiks\MyApplication.exe) .