Iexpress - 提取路径 [英] Iexpress - extraction path

查看:37
本文介绍了Iexpress - 提取路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将创建一个自解压存档,但在连接默认解压路径时遇到问题.我想在与自解压存档程序相同的路径中解压我的文件.不幸的是,这些文件正在另一个路径(C:\Users\computer\AppData\Temp\IXP000.TMP)中提取.可以设置路径吗?

I am going to create a self extracting archive but I have got a problem connecting with the default path of the extraction. I would like to extract my files in the same path as the self-extraction archive program. Unfortunately, the files are extracting in another path (C:\Users\computer\AppData\Temp\IXP000.TMP). Is it possible to set the path?

推荐答案

我找不到任何直接方法来使用 IExpress 做到这一点,但我们可以应用一个技巧.

I can't find any direct way to do this with IExpress, but there is a trick we can apply.

但首先我要指出,使用 7-Zip 之类的东西真的很容易s 7zCon.sfx 模块(如果您需要做的只是将存档提取到当前目录,则无需提问).所以你可能只想尝试 IExpress 以外的东西.

But first I'll point out that this is really easy with something like 7-Zip's 7zCon.sfx module (if all you need to do is have the archive extract to the current directory, no questions asked). So you might just want to try something other than IExpress.

无论如何,IExpress 的问题在于,当我们的安装程序运行时,我们不再位于原始存档的目录中;当前目录现在类似于 %temp%\IXP000.TMP.所以我们需要找到我们父进程的目录——有点痛苦.一旦知道了这一点,我们就可以xcopy 将存档的内容复制到目标文件夹中.

Anyhow, the problem with IExpress is that, at the time our install program runs, we're no longer in the directory of the original archive; the current directory is now something like %temp%\IXP000.TMP. So we need to find the directory of our parent process – kind of a pain. Once that's known, we can just xcopy the contents of the archive over to the destination folder.

在 VBScript 中,它看起来像这样:

In VBScript, it would look something like this:

Option Explicit

Dim objShell, objWMI
Dim objCmd, intMyPid, intMyParentPid, objMyParent

Set objShell = CreateObject("WScript.Shell")
Set objWMI = GetObject("winmgmts:root\cimv2")

Set objCmd = objShell.Exec("cmd.exe")
intMyPid = objWMI.Get("Win32_Process.Handle='" & objCmd.ProcessID & "'").ParentProcessId
objCmd.Terminate

intMyParentPid = objWMI.Get("Win32_Process.Handle='" & intMyPid & "'").ParentProcessId
Set objMyParent = objWMI.Get("Win32_Process.Handle='" & intMyParentPid & "'")

objShell.Run "xcopy /y * " & """" & Left(objMyParent.ExecutablePath, _
    InStrRev(objMyParent.ExecutablePath, ".exe", -1, vbTextCompare) -1) &_
    "\""", 0, True

您的安装程序将是,例如:wscript extractToOriginalLocation.vbs//B.

(受到对这个问题的回答的启发.)

(Inspired somewhat by the answer to this question.)

这篇关于Iexpress - 提取路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆