Jump to content

@Programfilesdir and 64 bit windows...


Recommended Posts

FileCopy(@ScriptDir & "\a.exe" , @ProgramFilesDir & "\a\", $FC_OVERWRITE)

I'm using 64 bit Windows 7. I want to copy a.exe to "C:Program Filesa". Not "C:Program Files (x86)a". But "@ProgramFilesDir" send a.exe to "C:Program Files (x86)a".

I read '?do=embed' frameborder='0' data-embedContent>> but I can't do it. I try all codes. No matter what I did, it copied to "Program Files (x86)...". I want to copy it "Program Files..." in 64 bit Windows, not x86 path.

And I want to add onething. My script will be able to run at both windows(x86-x64) and copy a.exe to "Program Files" path not Program Files (x86) path...

Edited by Atakanbasturk
Link to comment
Share on other sites

 

try :

FileCopy(@ScriptDir & "\a.exe" , StringRegExpReplace(@ProgramFilesDir & "\a\"," \(x86\)",""), $FC_OVERWRITE)

thank you very much it works. I want to ask onething: When I write #RequireAdmin to my codes' top line, do all my codes working with "run as administrator"? For example:

#RequireAdmin

Case $idRAR
If @OSArch="X86" Then
ProgressOn("32 bit WinRAR", "İndiriliyor...", "0%")
$url = "http://www.rarlab.com/rar/wrar501tr.exe"
$folder = @DesktopDir & "\winrartürkçe.exe"
$hInet = InetGet($url, $folder, 1, 1)
$FileSize = InetGetSize($url)
While Not InetGetInfo($hInet, 2)
    Sleep(500)
    $BytesReceived = InetGetInfo($hInet, 0)
    $Pct = Int($BytesReceived / $FileSize * 100)
    ProgressSet($Pct, $Pct & "%")
WEnd
ProgressOff()
Run("winrartürkçe.exe /S")
ProcessWaitClose("winrartürkçe.exe")
FileDelete(@DesktopDir & "\winrartürkçe.exe")
Sleep(1000)
ProcessClose("WinRAR.exe")
FileCopy(@ScriptDir & "\rarreg.key" , @ProgramFilesDir & "\WinRAR\", $FC_OVERWRITE)
TrayTip("WİNRAR Türkçe 32 bit", "Winrar kurulumu tamamlanmıştır!", 10)
Sleep(3000)
ElseIf @OSArch="X64" Then
ProgressOn("64 bit WinRAR", "İndiriliyor...", "0%")
$url = "http://www.rarlab.com/rar/winrar-x64-501tr.exe"
$folder = @DesktopDir & "\winrartürkçe64.exe"
$hInet = InetGet($url, $folder, 1, 1)
$FileSize = InetGetSize($url)
While Not InetGetInfo($hInet, 2)
    Sleep(500)
    $BytesReceived = InetGetInfo($hInet, 0)
    $Pct = Int($BytesReceived / $FileSize * 100)
    ProgressSet($Pct, $Pct & "%")
WEnd
ProgressOff()
Run("winrartürkçe64.exe /S")
ProcessWaitClose("winrartürkçe64.exe")
Sleep(1000)
ProcessClose("WinRAR.exe")
FileDelete(@DesktopDir & "\winrartürkçe64.exe")
FileCopy(@ScriptDir & "\rarreg.key" , StringRegExpReplace(@ProgramFilesDir & "\WinRAR\"," \(x86\)",""), $FC_OVERWRITE)
TrayTip("WİNRAR Türkçe 64 bit", "Winrar kurulumu tamamlanmıştır!", 10)
Sleep(3000)
EndIf

Or

#RequireAdmin

ase $idRAR
If @OSArch="X86" Then
ProgressOn("32 bit WinRAR", "İndiriliyor...", "0%")

#RequireAdmin

$url = "http://www.rarlab.com/rar/wrar501tr.exe"
$folder = @DesktopDir & "\winrartürkçe.exe"
$hInet = InetGet($url, $folder, 1, 1)
$FileSize = InetGetSize($url)
While Not InetGetInfo($hInet, 2)
    Sleep(500)
    $BytesReceived = InetGetInfo($hInet, 0)
    $Pct = Int($BytesReceived / $FileSize * 100)
    ProgressSet($Pct, $Pct & "%")
WEnd
ProgressOff()
Run("winrartürkçe.exe /S")
ProcessWaitClose("winrartürkçe.exe")
FileDelete(@DesktopDir & "\winrartürkçe.exe")
Sleep(1000)
ProcessClose("WinRAR.exe")

#RequireAdmin

FileCopy(@ScriptDir & "\rarreg.key" , @ProgramFilesDir & "\WinRAR\", $FC_OVERWRITE)
TrayTip("WİNRAR Türkçe 32 bit", "Winrar kurulumu tamamlanmıştır!", 10)
Sleep(3000)

ElseIf @OSArch="X64" Then
ProgressOn("64 bit WinRAR", "İndiriliyor...", "0%")

#RequireAdmin

$url = "http://www.rarlab.com/rar/winrar-x64-501tr.exe"
$folder = @DesktopDir & "\winrartürkçe64.exe"
$hInet = InetGet($url, $folder, 1, 1)
$FileSize = InetGetSize($url)
While Not InetGetInfo($hInet, 2)
    Sleep(500)
    $BytesReceived = InetGetInfo($hInet, 0)
    $Pct = Int($BytesReceived / $FileSize * 100)
    ProgressSet($Pct, $Pct & "%")
WEnd
ProgressOff()
Run("winrartürkçe64.exe /S")
ProcessWaitClose("winrartürkçe64.exe")
Sleep(1000)
ProcessClose("WinRAR.exe")

#RequireAdmin

FileDelete(@DesktopDir & "\winrartürkçe64.exe")
FileCopy(@ScriptDir & "\rarreg.key" , StringRegExpReplace(@ProgramFilesDir & "\WinRAR\"," \(x86\)",""), $FC_OVERWRITE)
TrayTip("WİNRAR Türkçe 64 bit", "Winrar kurulumu tamamlanmıştır!", 10)
Sleep(3000)
EndIf

I mean one "#RequireAdmin" to top line is enough for whole codes and works or, should I write "#RequireAdmin" for each different work(copy, delete,run works)???

You know except Professional and Ultimate, Windows request administrator rigths for many things and can block some autoit works.

Edited by Atakanbasturk
Link to comment
Share on other sites

Once is fine, you are just prompting for UAC.  Once elevated, your script (and most processes that you call from your script) will then run elevated as well.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

For the ProgramFiles location, you can also get it in the registry (I think it's a sure way) :)

$programFilesDir = RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
MsgBox(0, "", $programFilesDir)
Link to comment
Share on other sites

Atakan,

just for your information.

@ProgramFilesDir macro depends also how you start your compiled script. If it is compiled as x64 @ProgramFilesDir is C:Program Files, as x86 is C:Program Files (x86).

The 64-bit version can only be installed when the os architecture supports x64 execution.

 

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 7 months later...

Compile your code for both x86 and x64 (control F7), the autoit wrapper will include these lines to the top of the program.

 

#AutoIt3Wrapper_Outfile=PostInvNS32.exe
#AutoIt3Wrapper_Outfile_x64=PostInvNS64.exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y

Now the @ProgramFilesDir will Reference C:Program files

Good Luck

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