I have created a custom "application" where I converted a half dozen vbscripts that are individually run, into an AMS5 app. I did this due to the lack of "src\somepath" (relative path) capabilities in vbscript. This became an issue because this app, and the vbscripts it was developed from are run from removable media cards, that are used in a usb multi-card reader. When one broke, and I replaced it with a different style, the drive letter for the card I use changed so I had to modify all the scripts. Good candidate for an AMS5 app...
So all the scripts were easy to convert, and they all work except one. One fires off an install exe, which works great, one edits several registry keys, which works great, one copies updated files into the folder that the install portion installed to, and that work as well, one copies a backup installation folder and files to the hard drive and that works great too.
So here's where the problem gets weird. The offending routine is copying an empty access database over an existing one to "cleanup the database" prior to shipping this "custom unit" to a customer.
Both PC's I've run this on are Win2k OS and both are run as admin. On the PC I built the AMS5 app on, this copy works fine, both running it from inside the build in "preview" mode, and after I do the build, and copy everything to the media card, it still works fine.
When I take this card/app to the 2nd PC, the file copy doesn't happen OR return any error. If I just call the vbscript, it works.
Here's the failing code:
emptyresult = Dialog.Message("Empty Instrument Database", "This will empty the Instrument Database and give the customer a fresh database to start with, is this what you wanted to do?", MB_YESNOCANCEL, MB_ICONQUESTION, MB_DEFBUTTON1);
if emptyresult == 6 then -- yes button pressed
-- The line below works ok on my pc locally, even running the app off the usb drive, but will not copy on the Iris PC
-- for some strange reason. Going to try the vbscript call instead.
File.Copy("C:\\DetectorDirector\\InstrumentDataEmp ty.mdb", "C:\\DetectorDirector\\InstrumentData.mdb", false, true, false, true, nil);
EmptyCompleteResult = Dialog.Message("Empty Database Complete", "The Instrument Database has been emptied! Do NOT run any more calibrations before packing and shipping the unit!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
-- The vbscript works fine
-- File.Open("Scripts\\Iris Database Cleanup.vbs", "", SW_SHOWNORMAL);
--Check to see if an error occurred.
error = Application.GetLastError();
-- If an error occurred, display the error message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end
else
end
If I comment out the file copy and uncomment the file open, it works sweet.
Here's the vbscript that works:
Dim Response
Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
'Setup files and to copy and where they're going
Set f1 = fso.GetFile("C:\DetectorDirector\InstrumentDataEmp ty.mdb")
Set f2 = fso.GetFile("C:\DetectorDirector\InstrumentData.md b")
'Let's see if we REALLY want to empty the database
Response = MsgBox ("Are you SURE you want to empty the Scout Database?", 52, "Empty the Scout Database")
'We are NOT overwriting
If Response <> 6 Then
WScript.Echo "You DID NOT empty the IRIS Database!"
'Positive response let's move some stuff around
ElseIf Response = 6 Then
FSO.CopyFile f1, f2
WScript.Echo "The IRIS Database is cleaned up!"
End If
So I'm pretty puzzled, as both pieces of code do the same thing. The fact that the file.copy works on one machine and not the other has me stumped. Especially since it appears to work.
No big deal, as I found a work around, but thought maybe someone else had seen something similar.
Awesome flexibility with this program though!
Regards,
Bill

