Wednesday, March 28, 2012

7z SFX without the temp Config File

I prefer to not use temp files unless I absolutely need to so I replaced

001
002
003
$SetupConfig | out-File "$path\$ConfigName" -enc UTF8
get-content $SFX,$ConfigName,$ZipName -Enc Byte -Read 512 | set-content $OutName -Enc Byte

with:

001
002
003
004
005
$SFXBytes = [io.file]::ReadAllBytes("$PAth\$SFX")
$ConfigBytes = [text.encoding]::ascii.GetBytes($SetupConfig)
$ZipBytes = [io.file]::ReadAllBytes("$PAth\$ZipName")
($SFXBytes,$ConfigBytes,$ZipBytes| set-content $OutName -Enc Byte

I would like to have 7z build the zip to STDOUT but I don't think I can have it go to the 7z format.  Will continue to look at it.

This was an update to http://import-powershell.blogspot.com/2012/03/powershell-7zip-sfx-installer.html

No comments:

Post a Comment