NoNo
NoNo

Reputation: 313

Extract files using 7z with vb2010 to %temp%

This is one of the revisions that i have tried. I couldn't quite figure out the 7zipsharp thing.

    Dim Arg1 As String = "x"
    Dim Zip As String = "apps\dat\sb.7z"
    Dim path As String = "-o%TEMP%\Updates\sb"
    Process.Start(
"apps\dat\7z.exe",
Arg1 + path + Zip)

I would also like for it to wait until extraction is done before executing the code.

This is the script currently in use.

@setlocal enableextensions
@pushd "%~dp0"   ::This is so the script doesn't default to %windir%
@start "" /wait 7z.exe X -o%temp%\dat\sb -y sb.7z
::@pause
@start "" /wait /D"%temp%\dat\sb" "setup.exe" %~dp0
@rd /s/q %temp%\dat

Currently I am using a button_click to access this script but i would like to be rid of the script. It is preferred that it extracts to the temp directory.

**********UPDATE************* This is the ending code that I used that worked.

    Dim temp As String = System.Environment.GetEnvironmentVariable("TEMP")
    Dim Arg1 As String = "x -o"
    Dim Zip As String = "apps\dat\sb.7z -y"
    Dim path As String = temp + "\Updates\sb"
    Process.Start("apps\dat\7z.exe", Arg1 + path + " " + Zip)

I moved the -o to Arg1 and removed the space so it would read -o%temp%\Updates\SB to the system.

Upvotes: 0

Views: 2062

Answers (1)

DarkWanderer
DarkWanderer

Reputation: 8866

Rewriting your code:

Dim Arg1 As String = "x"
Dim Zip As String = "apps\dat\sb.7z"
Dim path As String = "-o%TEMP%\Updates\sb"
Process.Start("apps\dat\7z.exe",Arg1 + " " + path + " " + Zip)
p.WaitForExit();
  • You've forgot to include spaces between arguments
  • You can invoke WaitForExit() function to wait for process completion
  • After unpacking, you can launch setup.exe similarly to 7zip

Upvotes: 1

Related Questions