Memnoch Posted August 9, 2007 Share Posted August 9, 2007 (edited) Hi, I have written a small script at work to do a rollout of a new version of an existing application. When this script ends it should display a message box stating that the script has completed and then exit gracefully. However this isn't always the case. Sometimes the last message box will never show or in other cases the window will appear but there is a Windows application failure box over it as well. I'm not doing anything clever. Just running a couple of applications as an admin, copying some files around and then using the Inetget to copy a large file over from a NAS box. This command runs in conjunction with a progress meter showing the percentage completed. When this finishes the script completes. I can't give much more info than that as I am posting from home. But I can post what I have when I get to work tomorrow. I am using the latest release version, 3.2.4.9, on Windows XP SP2. Edited August 9, 2007 by Memnoch Link to comment Share on other sites More sharing options...
Zedna Posted August 9, 2007 Share Posted August 9, 2007 Post your code and say what errors occurs. If it's in Run() then use Opt('RunErrorsFatal',0) If it's in COM then use ObjEvent ( "AutoIt.Error" [, "function name"] ) If it's in array bounds then always check with UBound() ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Memnoch Posted August 10, 2007 Author Share Posted August 10, 2007 ***** CODE BEGINS ****** ;------------------------------------------------------------- ;Script to install Siebel Version 5 and country specific Files ;------------------------------------------------------------- Opt ( "TrayIconDebug", 1 ) ; Disable user input BLockInput ( 1 ) ; Check to see if Linkstation can be found on the network $findLS = Ping ( "linkstation", 2000 ) If $findLS = 0 Then BlockInput ( 0 ) MsgBox ( 16, "Network check", "Cannot find Linkstation. Check network connection." ) Exit EndIf ; Check if users database exists on Linkstation If FileExists ( "\\linkstation\Databases\" & @UserName & "\sse_data.dbf" ) Then Else BlockInput ( 0 ) MsgBox ( 16, "Siebel Version 5", "Database not found. Please check that database exists on Linkstation." ) Exit EndIf ; Check if users dicdata.dat exists on Linkstation If FileExists ( "\\linkstation\Databases\" & @UserName & "\dicdata.dat" ) Then Else BlockInput ( 0 ) MsgBox ( 16, "Siebel Version 5", "Dicdata.dat not found. Please check that the dicdata.dat file exists on Linkstation." ) Exit EndIf ; Assign Administrative rights RunAsSet ("ADMIN_USERNAME", @Computername, "ADMIN_PASSWORD") ; Run the Siebel Version 5 MSI package Run ( "msiexec /i SiebelWebClient-GlobalXlence-English-7823-R01.msi" ) WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup" ) WinWaitNotActive ( "Siebel Web Client (English) v7.8.2.3 Setup", "Computing space requirements" ) ; Error trapping to halt script if application is already installed and continue installation if not If WinExists ( "Siebel Web Client (English) v7.8.2.3 Setup", "Application Maintenance" ) Then ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup", "Uninstall Siebel Web Client (English) v7.8.2.3", "Cancel" ) WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup", "Installation is not complete" ) ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup", "Installation is not complete", "&Exit Setup" ) WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup Canceled" , "Siebel Web Client (English) v7.8.2.3" ) ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup Canceled" , "Siebel Web Client (English) v7.8.2.3", "OK" ) BlockInput ( 0 ) MsgBox ( 64, "Siebel Version 5", "Siebel V5 has already been installed. Exiting." ) Exit Else WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup", "Unauthorized reproduction" ) ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup", "Unauthorized reproduction", "&Next >" ) WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup", "The settings for this application" ) ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup", "The settings for this application", "&Next >" ) WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup", "You can choose not to install" ) ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup", "You can choose not to install", "&Next >" ) WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup", "Click the Back button" ) ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup", "Click the Back button", "&Next >" ) WinWaitActive ( "Siebel 7.8.2.3 QF0396 Patch" ) WinWaitClose ( "Siebel 7.8.2.3 QF0396 Patch" ) WinWaitActive ( "Siebel Web Client (English) v7.8.2.3 Setup", "Click the Finish button to exit" ) ControlClick ( "Siebel Web Client (English) v7.8.2.3 Setup", "Click the Finish button to exit", "&Finish" ) WinWaitClose ( "Siebel Web Client (English) v7.8.2.3 Setup" ) EndIf ; Install Country specific Files Run ( "UK_PRD_5.0.exe" ) WinWaitActive ( "WinRAR self-extracting archive", "Installation progress" ) ControlClick ( "WinRAR self-extracting archive", "Installation progress", "Install" ) WinWaitActive ( "Confirm file replace", "The following file already exists" ) ControlClick ( "Confirm file replace", "The following file already exists", "Yes to &All" ) WinWaitClose ( "Confirm file replace", "The following file already exists" ) WinWaitClose ( "WinRAR self-extracting archive" ) ; Remove admin rights RunAsSet () ; Move old Siebel shortcuts to D:\System and copy new shortcuts to users desktop FileMove ( @UserProfileDir & "\Desktop\*Siebel*.lnk" , "D:\System\Old Siebel Links\", 9 ) FileCopy ( "C:\Documents and Settings\All Users\Desktop\*Siebel*.lnk", @UserProfileDir & "\Desktop\" ) ; Copy Siebel files to users laptop. FileCopy ( "\\linkstation\Databases\" & @UserName & "\dicdata.dat", "C:\Siebel\782\LOCAL\", 1 ) FileCopy ( "phce.cfg", "C:\Siebel\782\BIN\ENU\", 1 ) FileCopy ( "siebel.pocketpc_arm.CAB", "D:\System\Siebel V5 Files\PDA\", 9 ) DirRemove ( "D:\System\siebelPDA", 1 ) ; Copy Proxy Disable shortcut to users desktop FileCopy ( "D:\System\VPN Proxy\VPN.lnk", @UserProfileDir & "\Desktop\Proxy Disable.lnk", 1 ) ; Copy users database to the local machine showing a progress bar $filesize = InetGetSize ( "ftp://linkstation/disk1/Databases/" & @UserName & "/sse_data.dbf" ) InetGet ( "ftp://linkstation/disk1/Databases/" & @UserName & "/sse_data.dbf", "C:\Siebel\782\LOCAL\sse_data.dbf", 1, 1 ) ProgressOn ( "Database Download", "Database Completion", "0 percent" ) While @InetGetActive $Percent = Round (( @InetGetBytesRead / $filesize ) * 100, 0 ) ProgressSet ( $percent, $percent & " percent" ) Sleep ( 2000 ) Wend ProgressOff () ; Enable user input BlockInput ( 0 ) ; Notify script completion and check to see if database has been copied If FileExists ( "C:\Siebel\782\LOCAL\sse_data.dbf" ) Then MsgBox ( 64, "Siebel Version 5", "Siebel V5 has been successfully installed." ) Exit Else MsgBox ( 16, "Siebel Version 5", "Database not found. Files will need copying manually." ) EndIf ***** CODE ENDS ****** What we have found is that in ALL cases the script completes all tasks correctly. The only difference is that right at the end sometimes the window indicating the script has completed successfully, with or without the windows exception error window as well, and very occasionally it will not show either of those last windows at all. My gut feeling is that it might be something to do with the InetGet code and that somehow the script is exiting without this completing properly but the files are always intact and the correct size. Link to comment Share on other sites More sharing options...
Zedna Posted August 10, 2007 Share Posted August 10, 2007 In all Run() functions always specify full path to not be dependend on currect dir change Run ( "UK_PRD_5.0.exe" ) to Run ( "C:\Some dir\UK_PRD_5.0.exe" ) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Memnoch Posted August 10, 2007 Author Share Posted August 10, 2007 Thanks for that. Good advice. So rather than: Run ( "C:\Some dir\UK_PRD_5.0.exe" ) I could use something like: Run ( @ScriptDir & "\UK_PRD_5.0.exe" ) The reason I hadn't done this was all the install files are on USB keys except the large database so the paths would never change but point taken! Regarding the error I have another cut down script that uses elements of the above to only retrieve the database files if something goes wrong. ***** CODE BEGINS ****** ;---------------------------------------------------- ;Script to copy Siebel database files to users laptop ;---------------------------------------------------- Opt ( "TrayIconDebug", 1 ) ; Disable user input BLockInput ( 1 ) ; Check to see if Linkstation can be found on the network $findLS = Ping ( "linkstation", 2000 ) If $findLS = 0 Then BlockInput ( 0 ) MsgBox ( 16, "Network check", "Cannot find Linkstation. Check network connection." ) Exit EndIf ; Check if users database exists on Linkstation If FileExists ( "\\linkstation\Databases\" & @UserName & "\sse_data.dbf" ) Then Else BlockInput ( 0 ) MsgBox ( 16, "Siebel Version 5", "Database not found. Please check that database exists on Linkstation." ) Exit EndIf ; Check if users dicdata.dat exists on Linkstation If FileExists ( "\\linkstation\Databases\" & @UserName & "\dicdata.dat" ) Then Else BlockInput ( 0 ) MsgBox ( 16, "Siebel Version 5", "Dicdata.dat not found. Please check that the dicdata.dat file exists on Linkstation." ) Exit EndIf ; Copy Siebel database files to the users laptop FileCopy ( "\\linkstation\Databases\" & @UserName & "\dicdata.dat", "C:\Siebel\782\LOCAL\", 1 ) FileCopy ( "\\linkstation\Databases\" & @UserName & "\FILES\*.*", "C:\Siebel\782\LOCAL\FILES\", 1 ) $filesize = InetGetSize ( "ftp://linkstation/disk1/Databases/" & @UserName & "/sse_data.dbf" ) InetGet ( "ftp://linkstation/disk1/Databases/" & @UserName & "/sse_data.dbf", "C:\Siebel\782\LOCAL\sse_data.dbf", 1, 1 ) ProgressOn ( "Database Download", "Database Completion", "0 percent" ) While @InetGetActive $Percent = Round (( @InetGetBytesRead / $filesize ) * 100, 0 ) ProgressSet ( $percent, $percent & " percent" ) Sleep ( 2000 ) Wend ProgressOff () ; Enable user input BlockInput ( 0 ) ; Notify script completion and check to see if database has been copied If FileExists ( "C:\Siebel\782\LOCAL\sse_data.dbf" ) Then MsgBox ( 64, "Siebel Version 5", "Siebel database has been successfully copied." ) Exit Else MsgBox ( 16, "Siebel Version 5", "Database not found. Please check and try again" ) EndIf ***** CODE ENDS ****** When I ran this earlier I received the error message. I have attached 2 JPEGs showing the error messages. However in that instance the completed successfully message box had also appeared. Oddly enough, when I wiped the laptop and ran the full install I did not receive the error message at all, indicating the randomness of it. Link to comment Share on other sites More sharing options...
Memnoch Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) I've been doing some more testing and pretty much identified that it is something to do with the FTP copy. If I replace:$filesize = InetGetSize ( "ftp://linkstation/disk1/Databases/" & @UserName & "/sse_data.dbf" ) InetGet ( "ftp://linkstation/disk1/Databases/" & @UserName & "/sse_data.dbf", "C:\Siebel\782\LOCAL\sse_data.dbf", 1, 1 ) ProgressOn ( "Database Download", "Database Completion", "0 percent" ) While @InetGetActive $Percent = Round (( @InetGetBytesRead / $filesize ) * 100, 0 ) ProgressSet ( $percent, $percent & " percent" ) Sleep ( 2000 ) Wend ProgressOff ()with:FileCopy ( "\\linkstation\Databases\" & @UserName & "\sse_data.dbf", "C:\Siebel\782\LOCAL\", 1 )The error message does not appear. We changed to an FTP transfer for two reasons. One was that we believed that it would be faster with multiple machines accessing the files and that we found that the NAS boxes were using would reboot when using FileCopy. A single machine would work but not multiple machines.If we wanted to swap back to using FileCopy instead of InetGet, is there a way to have the progress bar indicate progress as it does using FTP?Checking in the folder containing the application compatibilty error file it contains this but I'm not sure what to make of it to be honest.<?xml version="1.0" encoding="UTF-16"?><DATABASE><EXE NAME="DatabaseCopy.exe" FILTER="GRABMI_FILTER_THISFILEONLY"> <MATCHING_FILE NAME="DatabaseCopy.exe" SIZE="208080" CHECKSUM="0xE11CCBEA" BIN_FILE_VERSION="3.2.4.9" BIN_PRODUCT_VERSION="3.2.4.9" FILE_DESCRIPTION="" FILE_VERSION="3, 2, 4, 9" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x0" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="3.2.4.9" UPTO_BIN_PRODUCT_VERSION="3.2.4.9" LINK_DATE="05/25/2007 14:27:07" UPTO_LINK_DATE="05/25/2007 14:27:07" VER_LANGUAGE="English (United Kingdom) [0x809]" /></EXE><EXE NAME="kernel32.dll" FILTER="GRABMI_FILTER_THISFILEONLY"> <MATCHING_FILE NAME="kernel32.dll" SIZE="983552" CHECKSUM="0x4CE79457" BIN_FILE_VERSION="5.1.2600.2180" BIN_PRODUCT_VERSION="5.1.2600.2180" PRODUCT_VERSION="5.1.2600.2180" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xFF848" LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="5.1.2600.2180" UPTO_BIN_PRODUCT_VERSION="5.1.2600.2180" LINK_DATE="08/04/2004 07:56:36" UPTO_LINK_DATE="08/04/2004 07:56:36" VER_LANGUAGE="English (United States) [0x409]" /></EXE></DATABASE> Edited August 13, 2007 by Memnoch Link to comment Share on other sites More sharing options...
Memnoch Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) Adding: Sleep ( 10000 ) inbetween: ProgressOff () and the FileExists at the end has confirmed, for me at least, that it is the FTP session as the application failure window immediately appears and then 10 seconds later the MsgBox appears indicating that the script has completed successfully. Edited August 13, 2007 by Memnoch Link to comment Share on other sites More sharing options...
Reaper HGN Posted August 13, 2007 Share Posted August 13, 2007 Just out of curiosity, does it work if you remove the progress code loop and change the inetget background parameter to 0? (ie wait for the download before proceeding) Link to comment Share on other sites More sharing options...
Memnoch Posted August 14, 2007 Author Share Posted August 14, 2007 (edited) Hi there, Yes it does. Sorry, that was one other thing I had checked yesterday. It certainly seems to and I had done it by accident to be honest. I had changed it to 0 and left the ProgressSet loop in which then never got used. No errors! EDIT: Something else I was trying was application compatibility. I set it to Windows 2000 and immediately errored. As I type this I have it set to Windows 95 and it has ran through 7 times without the error. Switched compatibility mode off and the error popped up first time. Not sure how this helps me long term but at least it's a workaround. I also tried compiling the code with the latest beta and that made no difference either. EDIT2: Unfortunately when the application compatibility method is used on the full script which does the MSI installation, this then fails because of a policy in effect. Change this setting to Windows 2000 and the script proceeds but gives the error at the end. Either I have the MSI part as a second script which gets called from the first and runs without app. compat. or I live with the errors I guess. Edited August 14, 2007 by Memnoch Link to comment Share on other sites More sharing options...
Memnoch Posted August 17, 2007 Author Share Posted August 17, 2007 I seem to have come up with a somewhat inelligant solution to the problem. Since it seems to be keyed to the fact that the InetGet command is running in the background so that the ProgressSet loop can run after it I have removed this code from the main program, which will be called just before the InetGet runs and changed it to run in the foreground instead. So it appears as: Run ( @ScriptDir & \"ProgressMeter.exe" ) InetGet ( "ftp://linkstation/disk1/Databases/" & @UserName & "/sse_data.dbf", "C:\Siebel\782\LOCAL\sse_data.dbf", 1, 0 ) Where ProgressMeter will be: $filesize = FileGetSize ( "\\linkstation\Databases\" & @UserName & "\sse_data.dbf" ) $Downloaded = 0 ProgressOn ( "Database Download", "Database Completion", "0 percent" ) While $Downloaded < $filesize $Downloaded = FileGetSize ( "C:\Siebel\782\LOCAL\sse_data.dbf" ) $Percent = Round (( $Downloaded / $filesize ) * 100, 0 ) ProgressSet ( $percent, $percent & " percent" ) Sleep ( 2000 ) Wend ProgressOff () Exit I've tried this half a dozen times now and it has completed without the application failure. I would have preferred this to be in the one script though. Perhaps it could be created as a Function? I don't know much about these though so wil have to refer to the help file. Any suggestions gratefully received of course. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now