Jump to content
Sign in to follow this  
Ahmedmb

7 Zip Code

Recommended Posts

Ahmedmb

i write this Autoit Code to auto creat .7z files or .exe(from sfx Files)

but ExE file after built not run the program in SFX comint it alwyes run setup.exe

i don't know wherr is error??!!!

;----------------------------------------------------------------------------
; AutoIt Version: 3.1.0
; Author: Ahmed Bayomy
; ----------------------------------------------------------------------------
if not FileExists("7za.exe") then FileCopy(@ProgramFilesDir & "\7-zip\7za.exe",@ScriptDir & "\7za.exe")
if not FileExists("7z.sfx") then FileCopy(@ProgramFilesDir & "\7-zip\7z.sfx",@ScriptDir & "\7z.sfx")
if not FileExists("7zs.sfx") then FileCopy(@ProgramFilesDir & "\7-zip\7zs.sfx",@ScriptDir & "\7zs.sfx")

if $CmdLine[0] =0 then 
MsgBox(0,"Help","Parameters : " & @CRLF & " Folder name to creat 7z file " & @CRLF & " /SFX to creat .EXE " & @CRLF & " Filename to make .exe with autorun this file")
Exit
EndIf

dim $Command,$File
$7zFile='"' & $CmdLine[1] & '.7z"' 
$Command="7za.exe a -t7z -mx9 " & $7zFile & ' "' & $CmdLine[1] & '\*" -r -y'
RunWait($Command,"",@SW_HIDE )
if $CmdLine[0] >1 then 
if $CmdLine[2]="/SFX" Then
RunWait(@ComSpec & " /c " & "Copy /b " & @ScriptDir & "\7z.sfx + " & $7zFile & ' "' & $CmdLine[1] & '.exe"',"",@SW_HIDE) 
FileDelete($7zFile)
Else
;~ -----------------------------
dim $7TXT
$7TXT=FileOpen(@ScriptDir & "\7z.txt",2)
FileWrite($7TXT,";!@Install@!UTF-8!" & @CRLF)
FileWrite($7TXT,"RunProgram=" & '"' & $CmdLine[2] & '"' & @CRLF)
FileWrite($7TXT,";!@InstallEnd@!" & @CRLF)
RunWait(@ComSpec & " /C " & 'Copy /b "' & @ScriptDir & '\7zs.sfx" + "' & @ScriptDir & '\7z.txt" + ' & $7zFile & ' "' & $CmdLine[1] & '.exe"');,"",@SW_HIDE) 
EndIf
EndIf

:)

au3SFX.au3

Share this post


Link to post
Share on other sites
Alterego

i use 7zip in one of my progs. maybe seeing my syntax will help

RunWait(@ComSpec & ' /c ' & '7z a ' & $wttSet2[$wikiLoop] & "_" & $lang[$langLoop] & "_" & $plat[$platLoop] & "_TXT.zip " & $wttSet2[$wikiLoop] & "_" & $lang[$langLoop] & "_" & $plat[$platLoop] & "_TXT.tr3>>" & $logFile, @HomeDrive & '\' & $wikiFull[$wikiLoop] & '\' & $lang[$langLoop] & '\' & $plat[$platLoop] & '\', @SW_HIDE)

edit...that's probably confusing =)

RunWait(@ComSpec & ' /c ' & '7z a ' & 'file.zip ' & 'file.txt', @WorkingDir, @SW_HIDE)
Edited by Alterego

Share this post


Link to post
Share on other sites
Ahmedmb

What's mening of all thes Variable???

Share this post


Link to post
Share on other sites
Ahmedmb

can u add Completed code?

Share this post


Link to post
Share on other sites
Alterego

first, make sure you put 7za.exe in your @HomDriv & '\Windows\ directory. i renamed mine to 7z

RunWait(@ComSpec & ' /c ' & '7za a -t7z -mx9 " & $7zFile & ' "' & $CmdLine[1] & '\*" -r -y',"",@SW_HIDE )

Share this post


Link to post
Share on other sites
Ahmedmb

THX but thes will not creat exe file?

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  

×