Jump to content

Unable to run compiled *.exe script on another PC


zotchy
 Share

Recommended Posts

Hello,

I have a problem with running of compiled *.exe script on another PC.

This issue appears after adding following code:

If $msg = $button Then
   $output = ''
   $conn = ObjCreate("ADODB.Connection")
   $DSN = "DRIVER={SQL Server};SERVER=name;DATABASE=name;UID=name;PWD=pass;Trusted_Connection=False;"
   $conn.Open($DSN)
   $rs = ObjCreate( "ADODB.RecordSet" )
   $rs.Open( "select * from x", $conn )
   if $rs.RecordCount Then
    while not $rs.EOF
     $output &= $rs.Fields(0).Value & ' '& $rs.Fields(1).Value & @CRLF
     $rs.MoveNext
    WEnd
   EndIf
   GUICtrlSetData($editgui, $output)
   $conn.close
EndIf

This script connects to SQL server, recieve data and send to Edit control GUI.

This script is running fine in *.au3. It's running fine in compiled *.exe status. But only on PC where I developed it.

When I try to run it on different PC it shows following: "Error: The requested action with object has failed.". I was trying to add error handler but it didn't show me anything in *.exe build. Only provided message.

Did I miss something? I thought compiled script should contains all required functions and libraries. No?

Link to comment
Share on other sites

You'll have to debug a bit more (line by line, check status of objects, etc), but I would guess your other PC is having trouble creating the ADODB.Connection object, or is having trouble connecting to the database for some reason (since you are not checking if $conn.Open is successful). If so, that is not AutoIt's fault.

Edited by wraithdu
Link to comment
Share on other sites

When I try to run it on different PC it shows following: "Error: The requested action with object has failed.". I was trying to add error handler but it didn't show me anything in *.exe build. Only provided message.

Post your script with error handler. If it's correctly written then it will say exact error text.

Also check if server/database have the same name as on your PC.

Link to comment
Share on other sites

This the part of script. Not full, because it is very big:

#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>

;------------handler---
Func MyErrFunc()
  $hexnum=hex($objErr.number,8)
  Msgbox (0,"","We intercepted a COM Error!!"     & @CRLF               & @CRLF & _
             "err.description is: " & $objErr.description   & @CRLF & _
             "err.windescription is: " & $objErr.windescription & @CRLF & _
             "err.lastdllerror is: "   & $objErr.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & $objErr.scriptline   & @CRLF & _
             "err.number is: "     & $hexnum               & @CRLF & _
             "err.source is: "     & $objErr.source     & @CRLF & _
             "err.helpfile is: "       & $objErr.helpfile     & @CRLF & _
             "err.helpcontext is: " & $objErr.helpcontext _
    )
  exit
EndFunc


;------------------connection------
If $msg = $runbacklog_rus Then
   $output = ''
   $conn = ObjCreate("ADODB.Connection")
   $DSN = "DRIVER={SQL Server};SERVER=srv;DATABASE=db;UID=user;PWD=pass;Trusted_Connection=False;"
   $conn.Open($DSN)
   $rs = ObjCreate( "ADODB.RecordSet" )
   $rs.Open( "[select]", $conn )
   if $rs.RecordCount Then
    while not $rs.EOF
     $output &= $rs.Fields(0).Value & ' '& $rs.Fields(1).Value & @CRLF
     $rs.MoveNext
    WEnd
   EndIf
   GUICtrlSetData($backlog_gui, $output)
   $conn.close
EndIf

The script was working fine before I add ADODB.Connection objects

The server/DB names are the same on each PC.

Edited by zotchy
Link to comment
Share on other sites

Is the line

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")
somewhere in your script (should be on top of your code)?

If this line is missing then the error handler will never be called!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Is the line

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")
somewhere in your script (should be on top of your code)?

If this line is missing then the error handler will never be called!

I am sorry. Of course, I have $objErr = ObjEvent("AutoIt.Error","MyErrFunc") just above the handler.
Link to comment
Share on other sites

Great, can you post a screenshot of the MsgBox you get?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Dear Zedna,

Thank you very much for your help. I think I know what this issue about. It is all about connection. Not with server but with creadentials. The SQL is using Windows Authentification. And it is not possible to use connection under another account(((. That's why script returns error.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...