Sign in to follow this  
Followers 0
Briandr

quick question on compiling

7 posts in this topic

Hi,

I got batch file that I want to run hidden using a compiled EXE from AutoIT. Here is what would be in the compiled EXE

Run("C:testbatchfile.bat", "", @SW_HIDE)

So the EXE runs the batch which opens a self extracting EXE created by WinRAR. Once the file is out and in %temp% it checks to see if the system it is running against is and x86 or x64. No biggie. You guys probably don't even need to know that, but just some quick info.

What I'd like to know is do I create the EXE with AutoIT using the 32-bit version? I would assume so, but just bare in mind the EXE created from AutoIT would need to be run on an x86 and x64 systems. I know you can run x86 on x64, but x64 can't run on x86.

Perhaps I am having brain fart. Just wanted to doublecheck.

Thanks guys.

Share this post


Link to post
Share on other sites



Hi, Briandr. My first question is why you're running an AutoIt script to call a batch file to open a WinRAR file. Have you looked into simply calling the WinRAR file from the AutoIt script?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

If you want it to support both architectures then use 32 bit yes. To be honest, there is hardly any difference for your purposes.

Share this post


Link to post
Share on other sites

Hi,

Thanks guys for replying. Little clarification. Not yet using an AutoIT EXE. Right now I have a self extracting EXE created from WinRAR that contains a batch file that is extracted to %temp% and run. It opens in plain view. The user could click x and stop it. My thought would be to extract the AutoIT EXE and the batch file to %temp% and then run the AutoIT EXE.

To the first poster if I do as suggested and call the WinRAR EXE from AutoIT I still need to hide the command window that the batch file in the WinRAR EXE that will run. Can AutoIT help with that?

Share this post


Link to post
Share on other sites

Yes, please post the contents of your batch file, and we can assist in getting it into your AutoIt script.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok. Here is the batch file.

After the batch is removed from the WinRAR EXE and placed into %temp% depending on the condition it may then pull out another file from the WinRAR EXE, Brian.scr and place it accordingly.

Thanks.

@ECHO OFF
Set RegVar=HKLMHardwareDescriptionSystemCentralProcessor0
REG.exe Query %RegVar% 2>NUL | find /I /N "x86">NUL
If [%ERRORLEVEL%] == [0] (
    echo X86
    cd %systemroot%system32
    If exist "brian.scr" ren "brian.scr" "brianold01.scr"
    GOTO FILEMOVE1
) ELSE (
    echo AMD64
        cd %systemroot%sysnative
    If exist "brian.scr" ren "brian.scr" "brianold01.scr"
    cd %windir%sysWOW64
    If exist "brian.scr" ren "brian.scr" "brianold01.scr"
        GOTO FILEMOVE2

)
:FILEMOVE1
COPY /Y "%~dp0brian.scr" "%systemroot%system32brian.scr"
exit
:FILEMOVE2
%systemroot%sysnativecmd.exe /c copy /y "%~dp0brian.scr" "%systemroot%system32brian.scr"
COPY /Y "%~dp0brian.scr" "%windir%sysWOW64brian.scr"
exit

Edited by Briandr

Share this post


Link to post
Share on other sites

Hi, Briandr. Here are my suggestions, line by line:

  • You're testing a reg key to see if the CPU Architecture is x86 or not. In AutoIt, there are several macros do to this (@CPUArch, @OSArch, etc.) Check the help file for more.
  • Based on that, you can do a FileMove to rename the old file
  • Then you can do a FileCopy to copy down your new file.

The help file has good examples for you on all of these functions. Please feel free to post back here if you get stuck.


√-1 2^3 ∑ π, and it was delicious!

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