Sign in to follow this  
Followers 0
RedFish

The difference in function run() between 32 and 64 bit OS

4 posts in this topic

Hello again helpful people,

I have a simple script that is quite specialized to our development team and saves us all a bunch of time when running and logging into our test environments. To summarize what the script does:

  • look for an installation of the thin client using @ProgramFilesDir
  • prompt the user for the parameters
    • host name
    • a flag for the script to run & login or just run
    • a flag for the script to run the environment in a debug mode
  • once the user has entered the required parameters and hit "OK", drop to the command line and run an exe file that should have been found in @ProgramFilesDir with the parameters given by the user.

>>> this is where i'm having issues

 

The utility runs and works on both architectures, but an issue arrives when hitting the "OK" button if the utility is being run in a 64 bit OS. The message I get reads:

Error: Error parsing function call.

I'm running on a 32 bit because our IDE only runs in that architecture, but support staff uses a mix.

I am guessing that it is the call to function run() that produces this error because that is where the error happens.

Is there a difference between calling function run() on a 64 bit OS with a 32 bit script?

Share this post


Link to post
Share on other sites



Without seeing your script it would be very difficult to trouble shoot the issue.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

BrewManNH,

Thanks for your reply. My script / application is quite specialized so you may experience things when running that users in our office environment wouldn't, but I think you could swap much of the specialization out for generalization like notepad if that would be a valid test.

Again, this code works 99.9% of the time when run on a 32bit OS, but so far has come to fruition 0% on 64bit OS because of the error described in the OP. 

PS: there is code here to create files and registry keys on the user system.

#cs----
Description:
    Run an instance of advantage with the debug option.
    
Parameters:
    Input box value must represent a networked virtual server running acu8.1.x [site number for login function is optional]
    
Remarks:
    This program assumes that the users environment has an installation of Acu 8.1.x in 'c:\Program Files\Acucourp\...'
    
    
#ce----

 
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <Array.au3>
;~ #include "./Includes/Downloads/_GetIntersection.au3"
#include "./Includes/CommonControlFunctions.au3"
#include "./Includes/Advantage_login.au3"

opt('WinTextMatchMode', 2)
opt('WinTitleMatchMode',1)
opt('TrayIconDebug', 1)
opt('GUIOnEventMode',1)

$Result = 1


Global $Window 
Global $WinList1
Global $WinList2
Global $arResults   
Global $InstallDir = @ProgramFilesDir & '\Acucorp\Acucbl810\'
;~ If @OSArch = "X64" Then
;~   $InstallDir = @ProgramFilesDir & ' (x86)\Acucorp\Acucbl810\'
;~ EndIf
ConsoleWrite('install dir: ' & $InstallDir & " arch: " & @OSArch & @LF)

Global $bDebug = ''
Global $hSvrFile
Global $hHost
Global $hSite
Global $hDebug
Global $okbutton
Global $cancelbutton
Global $hENTER
Global $hEsc

_Run8_1()

; wait for user event
while 1
   sleep(1000)
WEnd


Func _Run8_1()
   $Window = GUICreate("Run Adv",125,110)
    
    GUICtrlCreateLabel("Server name:", 5,5)
    GUICtrlCreateLabel('Site number:',5,45)
    
   ; check for ...\Program Files\8-1Run\serverList.txt exists
   If FileExists(@ProgramFilesDir & "\8-1Run\serverList.txt") Then
      ; true, use file to populate the combobox
      $hSvrFile = FileOpen(@ProgramFilesDir & "\8-1Run\serverList.txt")
      $txt = ''
      While 1
         $txt &= FileReadLine($hSvrFile) & "|"
         If @error = -1 Then 
            $txt = StringTrimRight($txt,2)
            ExitLoop
         EndIf
      WEnd    
      $hHost = _GUICtrlComboBox_Create($Window,$txt,5,20,115,20)
   Else
      ; false, assume the dir doesn't exist either and create both
      DirCreate(@ProgramFilesDir & "\8-1Run\")
      $hSvrFile = FileOpen(@ProgramFilesDir & "\8-1Run\serverList.txt",1)
      $hHost = _GUICtrlComboBox_Create($Window,'',5,20,115,20)
   EndIf
   FileClose($hSvrFile)
   
    ; look for previous server key and suggest as default
    $ReadSuccess = RegRead("HKEY_CURRENT_USER\SOFTWARE\USERDEF\AcuOpen", "LastServer")
    ConsoleWrite('Server key: ' & chrw(9) & $ReadSuccess & @lf)
   If $ReadSuccess <> '' Then
      _GUICtrlComboBox_SetEditText($hHost,$ReadSuccess)     
   EndIf
   
    
    ; look for previous site key and suggest as default
    $ReadSuccess = RegRead("HKEY_CURRENT_USER\SOFTWARE\USERDEF\AcuOpen", "LastLogin")
    ConsoleWrite('Login key: ' & chrw(9) & $ReadSuccess & @lf)
    IF $ReadSuccess <> '' And $ReadSuccess <> 0 Then
        $hSite = GUICtrlCreateInput($ReadSuccess,5,60,50,20)
    Else
        $hSite = GUICtrlCreateInput('',5,60,50,20)
    EndIf
    GUICtrlSetTip($hSite, "Optional to login as admin")
    
    
    ; look for previous debug setting key and use last value
    $hDebug = GUICtrlCreateCheckbox('debug', 65,60)
    $ReadSuccess = RegRead("HKEY_CURRENT_USER\SOFTWARE\USERDEF\AcuOpen", "DebugBool")
    ConsoleWrite('Debug key: ' & chrw(9) & $ReadSuccess & @lf)
    If $ReadSuccess <> '' Then 
        Select
        case $ReadSuccess = 'True'
            GUICtrlSetState($hDebug, $GUI_CHECKED)
        case Else
            GUICtrlSetState($hDebug, $GUI_UNCHECKED)
        EndSelect
    EndIf
    
    
    $okbutton = GUICtrlCreateButton("OK", 10,85,50,20)
    $cancelbutton = GUICtrlCreateButton("Cancel",65,85,50,20)
    
    $hENTER = GUICtrlCreateDummy()
    $hEsc = GUICtrlCreateDummy()
    dim $aAccel[2][2] 
    $aAccel[0][0] = '{ENTER}' 
    $aAccel[0][1] = $hENTER
    $aAccel[1][0] = '{Esc}'
    $aAccel[1][1] = $hEsc
    GUISetAccelerators($aAccel)
    
    ; set events for user interaction.
    GUICtrlSetOnEvent($hENTER, "_okayClicked")
    GUICtrlSetOnEvent($okbutton, "_okayClicked")
    GUICtrlSetOnEvent($hEsc, '_cancelClicked')
    GUICtrlSetOnEvent($cancelbutton, "_cancelClicked")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_cancelClicked")
    GUISetState(@SW_SHOW, $window)
    ControlFocus('','',$hHost)
    
EndFunc

;==================================================================================================
; Function Name:    _okayClicked()
; Description::     event for okay click / enter press
;                       - validate parameters
;                       - open new instance of advantage 
;
; Parameter(s):     read from screen controls
;
; Return Value(s):  1 - an error occurred - return to main window 
; Note:             - run with command prompt to produce consol logging
; Author(s):        josh gust (ddslive.com)
;==================================================================================================
Func _okayClicked()
    ConsoleWrite('okay clicked or enter presed' & @LF)
    $sName = ControlGetText('','',$hHost)
    $nSite = ControlGetText('','',$hSite)
    
    ; validate site parameter and set boolean value
    $login = True
    If $nSite = '' Then
        $login = False
    EndIf
    
    $nSite = Number($nSite)
    If $nSite = 0 Or Not IsInt($nSite) Then
        $login = False
    Else
        $Write = RegWrite("HKEY_CURRENT_USER\SOFTWARE\USERDEF\AcuOpen", "LastLogin", "REG_SZ", $nSite)
        If $Write = 0 Then 
            ConsoleWrite('Error:' & @lf & chrw(9) &'An error occurred trying to open and write the site key.' & @lf)
            MsgBox(0, 'Error:' , "Can't open and write key." & @lf)
        EndIf
    EndIf
    
    ; define var for -d option
    $option = GUICtrlRead($hDebug)
    
    ; Before calling the run command, search for the Acucorp\Acucbl810 directory in {C:\Program Files\} 
    ; If none is found then prompt the user with a message requiring an Acu8.1 installation.
    If FileExists($InstallDir) _ 
        And StringInStr(filegetattrib($InstallDir),"D") Then
            
            ; evaluate the checkbox and write reg key
            ConsoleWrite('checking debug box' & @lf)            
            If $option = 1 Then
                $option = ' -d '
                $Write = RegWrite("HKEY_CURRENT_USER\SOFTWARE\USERDEF\AcuOpen", "DebugBool", "REG_SZ", 'True')
                If $Write = 0 Then 
                    ConsoleWrite('Error:' & @lf & chrw(9) &'An error occurred trying to open and write the debug key.' & @lf)
                    MsgBox(0, 'Error:' , "Can't open and write key." & @lf)
                EndIf

                ; get a 2d list of debug windows
                $WinList1 = WinList('ACUCOBOL-GT Debugger')
                ConsoleWrite('WinList1 count: ' & $WinList1[0][0] & @LF)
                If $WinList1[0][0] = 0 then 
                    $first = True
                Else 
                    $first = False
;~                  $WinList2[0][0] = $WinList1[0][0]
                    ConsoleWrite('getting handle(s) from WinList 1' & @LF)
                    $WinList1 = _ListDebugHandles($WinList1)
                EndIf
            Else
                $option = ' '
                $Write = RegWrite("HKEY_CURRENT_USER\SOFTWARE\USERDEF\AcuOpen", "DebugBool", "REG_SZ", 'False')
                If $Write = 0 Then 
                    ConsoleWrite('Error:' & @lf & chrw(9) &'An error occurred trying to open and write the debug key.' & @lf)
                    MsgBox(0, 'Error:' , "Can't open and write key." & @lf)
                EndIf
            EndIf
            
            ; call run function and check pid
            ConsoleWrite('calling run()' & @LF)
            $PID = run('"' & $InstallDir & '\Acucorp\Acucbl810\AcuGT\bin\acuthin.exe" ' & _ 
                        '--nosplash --password nfsuser ' & $sName & $option & 'menu')
            If $PID = 0 and @error <> 0 Then    
                MsgBox(0, "Unable to Launch Process", "Check that the box is valid and running, " & @lf & _
                "and that the installation is located @:" & @lf & '"' & @ProgramFilesDir & '\Acucorp\Acucbl810\AcuGT\bin\acuthin.exe"'
                ConsoleWrite('Error:' & @lf & chrw(9) & _ 
                            "Unable to Launch Process. Check that the box is valid and running, " & @lf & chrw(9) & _
                            "and that the installation is located @:" & @lf & chrw(9) & - 
                            '"C:\Program Files\Acucorp\Acucbl810\AcuGT\bin\acuthin.exe"'& @lf)
            Else
               ; write the check passing value to registry | only write after successful run
               $Write = RegWrite("HKEY_CURRENT_USER\SOFTWARE\USERDEF\AcuOpen", "LastServer", "REG_SZ", $sName)
               If $Write = 0 Then 
                  ConsoleWrite('Error:' & @lf & chrw(9) & 'An error occurred trying to open and write the server key.' & @lf)
                  MsgBox(0, 'Error:', "Can't open and write key." & @lf)
               EndIf

               ; check the server file and write new line if needed
               ; ...
            EndIf
    Else
        MsgBox(0,'Acu 8.1 Not Found','This script requires an installation of Acucbl810.')
        ConsoleWrite('Error:' & @lf & chrw(9) & 'Installation not found' & _ 
                        @LF & chrw(9) & 'This script requires an installation of Acucbl810 in C:\Program Files\Acucorp' & @LF)
        Exit
    EndIf
            

    ; look for connection fail while checking for debug / Advantage window
    ConsoleWrite('enter connection loop' & @lf)
        dim $trycount =0
        While not WinExists("ACUCOBOL-GT Debugger") _ 
                    And Not WinExists("Advantage - ")
        
            If WinExists('ACUCOBOL-GT Thin Client', 'Connection failed') Then 
                $wintxt = WinGetText('ACUCOBOL-GT Thin Client')
                $wintxt = WinGetText('Error')
                $trimcount = StringInStr($wintxt, @lf)
                $wintxt = StringTrimLeft($wintxt, $trimcount)
                ConsoleWrite('Error:' & @lf & chrw(9) & $wintxt & @lf)
                WinWaitClose ( "ACUCOBOL-GT Thin Client", "Connection failed")
                ConsoleWrite('window closed' & @lf)
                Return 1
            EndIf
        
            If WinExists('Error', 'Program missing or inaccessible') Then 
                $wintxt = WinGetText('Error')
                $trimcount = StringInStr($wintxt, @lf)
                $wintxt = StringTrimLeft($wintxt, $trimcount)
                ConsoleWrite('Error:' & @lf & chrw(9) & $wintxt & @lf)
                WinWaitClose ('Error', 'Program missing or inaccessible')
                ConsoleWrite('window closed' & @lf)
                Return 1
            EndIf
            
            $trycount +=1           
            if $trycount > 60 then 
                If MsgBox(4, 'Time out', 'Do you want to keep waiting?') = 6 Then
                    $trycount = 0
                else 
                    Return 1
                EndIf
            EndIf
            sleep( 250 )    
        WEnd
    
    ; activate and click the go button if debug used
    dim $hWin
    
    If $option = ' -d ' Then
        If $first = False Then
            ; get a list of windows after the new opens
            Do 
                Sleep( 250 )
                $WinList2 = WinList("ACUCOBOL-GT Debugger")
            Until UBound($WinList2, 1) > UBound($WinList1)
            
            ; chop the names off the 2d array to only give 1d array and handles
            ConsoleWrite('WinList2 count: ' & $WinList2[0][0] & @LF)
            ConsoleWrite('getting handle(s) from WinList 2' & @LF)
            $WinList2 = _ListDebugHandles($WinList2)
            
            ; compare list before run() to list after to find new window
            For $i =0 To UBound($WinList2)-1
                _ArraySearch($WinList1, $WinList2[$i])
                If @error = 6 Then  ; value not found in array, use this one    
                    ConsoleWrite('@error: ' & @error & ' array diff found' & @LF)
                    $hWin = $WinList2[$i]
                    ConsoleWrite('hWin: ' & $hWin & @LF)
                    $i = UBound($WinList2)-1
                    ExitLoop    ; if this condition is met, then the until on the outer loop must also be met. So, this exits both loops.
                Else
                    ConsoleWrite($WinList2[$i] & ' : not new' & @lf)
                EndIf
            Next
        EndIf           
        
        ConsoleWrite('clicking $hWin' & @lf)
        WinActivate($hWin)  
        ConsoleWrite('clicking the button' & @lf)
        _ClickTheButton ( $hWin, '', "[CLASS:AcuBitButtonClass; INSTANCE:11]", .25)
    EndIf
    
    ; if login parameter is true, look for the window and call the login function
    If $login = True Then
        WinWait('Advantage Login','',1)
        ConsoleWrite('call login function' & @LF)
        _Advantage_Login("Admin", "United", $nSite)
    EndIf
    
    ; put focus back into the server box.
    ControlFocus('','',$hHost)
    ConsoleWrite(@lf)
    Return 1
EndFunc

;==================================================================================================
; Function Name:   _cancelClicked()
; Description::    exit the program when close event
; Parameter(s):    none
; Return Value(s): Succes   close the script
; Note:            
; Author(s):       josh gust (ddslive.com)
;==================================================================================================
Func _cancelClicked()
    ConsoleWrite('exiting' & @lf)
    Exit
EndFunc

;==================================================================================================
; Function Name:   _ListDebugHandles($set)
; Description::    Get the 1d array of handles from a 2d array of titles + handles
;                  
; Parameter(s):    $Set (2D-array of title + handle returned from WinList())
;                  
; Return Value(s): Succes   1D-array    $Return[$handle]
;
; Note:            Comparison is case-sensitiv! - i.e. Number 9 is different to string '9'!
; Author(s):       josh gust (ddslive.com)
;==================================================================================================
Func _ListDebugHandles($set)
    dim $aReturn[ubound($set,1)]
;~  ConsoleWrite('ubound aReturn: ' & ubound($aReturn) & @LF)
    For $i = 1 To UBound($set) -1
;~      ConsoleWrite('i : ' & $i & @lf)
        ConsoleWrite('$set '&$i&',1: ' & $set[$i][1] & @lf)
        $aReturn[$i-1] = $set[$i][1]
        
    Next
    
    Return $aReturn     
 EndFunc    
 
Edited by RedFish

Share this post


Link to post
Share on other sites

Run sets @error so it would have not created the error Msgbox. It was probably the Msgbox called after Run that caused it as it had no closing brace. Au3Check can help to spot these kind of syntax errors.

Try this partial section which had bad paths and syntax errors as an update in your script.

$PID = run('"' & $InstallDir & '\AcuGT\bin\acuthin.exe" ' & _ ; FIXED PATH ON LINE 215
                        '--nosplash --password nfsuser ' & $sName & $option & 'menu')
            If $PID = 0 and @error <> 0 Then
                MsgBox(0, "Unable to Launch Process", "Check that the box is valid and running, " & @lf & _
                "and that the installation is located @:" & @lf & '"' & $InstallDir & '\AcuGT\bin\acuthin.exe"'); FIXED MISSING BRACE AND PATH
                ConsoleWrite('Error:' & @lf & chrw(9) & _
                            "Unable to Launch Process. Check that the box is valid and running, " & @lf & chrw(9) & _
                            "and that the installation is located @:" & @lf & chrw(9) & _ ; FIXED CONTINUATION CHARACTER
                            '"' & $InstallDir & '\AcuGT\bin\acuthin.exe"'& @lf) ; FIXED PATH
            Else

Ensure you test as being a 32 bit process and see how it goes.

Share this post


Link to post
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
Sign in to follow this  
Followers 0