Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 使用7z和vb2010将文件提取到%temp%_.net_Vb.net_Visual Studio 2010_7zip - Fatal编程技术网

.net 使用7z和vb2010将文件提取到%temp%

.net 使用7z和vb2010将文件提取到%temp%,.net,vb.net,visual-studio-2010,7zip,.net,Vb.net,Visual Studio 2010,7zip,这是我尝试过的修订之一。我不太明白七弦琴是怎么回事 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) 我还希望它在执行代码之前等待提取完成 这是当前正在使用的脚本 @setlocal enableex

这是我尝试过的修订之一。我不太明白七弦琴是怎么回事

    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)
我还希望它在执行代码之前等待提取完成

这是当前正在使用的脚本

@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
目前我正在使用一个按钮点击访问这个脚本,但我想摆脱脚本。最好将其解压缩到临时目录

************更新************** 这是我使用的有效的结束代码

    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)
我将-o移到Arg1并删除了空间,以便它将-o%temp%\Updates\SB读到系统中。

重写代码:

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();
  • 您忘记了在参数之间包含空格
  • 您可以调用WaitForExit()函数来等待进程完成
  • 解包后,可以像7zip一样启动setup.exe

谢谢黑暗者,有机会我会试试的。我对正在使用的服务器非常着迷,因此不得不将其放在后台。其中一个问题是,它提取到应用程序主文件夹中的%temp%,而不是C:\\appdata\local\t中的%temp%。这可以通过使用Environment.ExpandEnvironmentVariables(路径)进行修复。可能需要将“-o”部分移动到Arg1字符串中。谢谢,我将使用它,但我至少有了第一部分,谢谢你。:)