0

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.

NoNo
  • 315
  • 1
  • 4
  • 13

1 Answers1

1

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
DarkWanderer
  • 8,739
  • 1
  • 25
  • 56
  • Thanks DarkWanderer, I'll try it when I get a chance. I've been so caught up in the server I'm working on that I have had to put this in the background. – NoNo Nov 17 '12 at 05:32
  • One issue with this is that it extracts to %temp% in apps home folder not %temp% as in C:\\appdata\local\temp – NoNo Nov 18 '12 at 00:52
  • This can be fixed by using Environment.ExpandEnvironmentVariables(path ). Moving "-o" part into Arg1 string may be required. – DarkWanderer Nov 18 '12 at 10:03
  • Thanks I will work with it but I at least I have the first part down thanks to you. :) – NoNo Nov 19 '12 at 20:43