Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Unable to run compiled *.exe script on another PC


  • Please log in to reply
12 replies to this topic

#1 zotchy

zotchy

    Seeker

  • Active Members
  • 20 posts

Posted 07 November 2011 - 07:10 AM

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?







#2 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,389 posts

Posted 07 November 2011 - 03:03 PM

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, 07 November 2011 - 03:04 PM.


#3 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,557 posts

Posted 07 November 2011 - 03:36 PM

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.

#4 zotchy

zotchy

    Seeker

  • Active Members
  • 20 posts

Posted 09 November 2011 - 08:00 AM

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

Plain Text         
#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, 09 November 2011 - 08:02 AM.


#5 water

water

    ?

  • MVPs
  • 14,584 posts

Posted 09 November 2011 - 08:08 AM

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, 09 November 2011 - 08:09 AM.

UDFs:
Active Directory (NEW: 2014-02-17 - Version 1.4.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2013-11-10 - Version 0.10.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel (NEW: 2014-03-22 - Beta 5) - Download - General Help & Support - Example Scripts


#6 zotchy

zotchy

    Seeker

  • Active Members
  • 20 posts

Posted 09 November 2011 - 08:23 AM

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.

#7 water

water

    ?

  • MVPs
  • 14,584 posts

Posted 09 November 2011 - 08:25 AM

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

UDFs:
Active Directory (NEW: 2014-02-17 - Version 1.4.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2013-11-10 - Version 0.10.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel (NEW: 2014-03-22 - Beta 5) - Download - General Help & Support - Example Scripts


#8 zotchy

zotchy

    Seeker

  • Active Members
  • 20 posts

Posted 09 November 2011 - 08:49 AM

We have here the error line, but I do not have line with such number. During compilation it compiles all libraries which I use in script. So it is very hard to determine exact line.
Posted Image

#9 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,557 posts

Posted 09 November 2011 - 09:17 AM

This error is not from your COM error handler.
Try to test @error after ObjCreate()

#10 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,557 posts

Posted 09 November 2011 - 09:20 AM

   $conn.close

Also this is safe way how to do closing:
    If IsObj($conn) And $conn.State > 0 Then $conn.Close


#11 zotchy

zotchy

    Seeker

  • Active Members
  • 20 posts

Posted 09 November 2011 - 09:52 AM

Zedna,

I added:

$conn = ObjCreate("ADODB.Connection")
@error

Also I changed connection closure line.

The message is the same.

#12 zotchy

zotchy

    Seeker

  • Active Members
  • 20 posts

Posted 09 November 2011 - 10:03 AM

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.

#13 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,389 posts

Posted 09 November 2011 - 05:16 PM

So you ignored what I said in post #2 then? Good to know.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users