Jump to content

Running 64 Bit script from 32 Bit script - more gracefully?


JerryD
 Share

Recommended Posts

Where I work we are nearly fully imbeded in 64 Bit Windows - but not completely.  If I compile a script, I'd like to run the 32 bit version, but invoke the 64 bit version if the appropriate OS is running.

So far this is a sample of what I've come up with.

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=1.4.0.0
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_Run_After=copy /Y "%outx64%" "C:\Temp\*.*"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WinAPIFiles.au3>

#Region 64 Bit Switch
If @Compiled AND StringInStr(@ScriptName,'_x64')=0 AND @OSArch='X64' Then
    FileInstall ( 'C:\Temp\64BitTest_X64.exe', @TempDir & '\64BitTest_X64.exe', 1 )
    Run ( @TempDir & '\64BitTest_X64.exe' )
    Exit
EndIf
#EndRegion 64 Bit

OnAutoItExitRegister ( 'MyExit' )

MsgBox ( 0, '@ScriptFullPath - Version', @ScriptFullPath & @CRLF & 'Version: ' & FileGetVersion ( @ScriptFullPath) )

#Region Functions
Func MyExit()
    If @Compiled AND StringInStr(@ScriptName,'_x64') Then
        _WinAPI_MoveFileEx ( @ScriptFullPath, Null, $MOVE_FILE_DELAY_UNTIL_REBOOT )
    EndIf
    Exit
EndFunc
#EndRegion Functions

This works fine but there are a couple of minor problems with it - specfically that you have to compile the script twice to get the current version of the script in the 32 bit version via FileInstall.  I'm also not crazy about leaving the 64 bit version in the Temp directory until the next reboot, but it doesn't bother me as much as the needing to compile twice.

Does anyone hae a more graceful way to do this that doesn't require compiling the script twice?

Thanks!

Edited by JerryD
Link to comment
Share on other sites

Yes, compile for x86 only and go away with that.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Are you doing something in the 64-bit version, that cannot be done when running a 32-bit version on a 64-bit system?  Have a look at "Running under Windows 64-bit Edition."  If you absolutely need to something in 64-bit, then you have no choice but to have two compiled scripts.  

Also, if your worried about the 64-bit script being left in temp, then have it delete itself after it is run.  Have a look at >guinness' _SelfDelete UDF.  

 

Adam

Link to comment
Share on other sites

Giving first a valid explanation why you insist on having two separate versions would greatly help us help you.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

There are some APIs that are available only for x64 apps on x64-based systems. I'm not saying that's the case here however.

Btw, some Microsoft's utilities come as x86 executable with embedded x64 version, which is then run for systems that would require it. I believe Sysinternals' process explorer is such utility.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

trancexx,

I'm fully aware of that but I'd say that the vast majority of applications for which users seek the kind of help like this one on this forum rarely have to face such issue. Time has shown that most of the times, people just don't know that general-purpose x86 code runs like magic on a x64 Windows.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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...