我找不到任何direct使用 IExpress 可以实现此目的,但我们可以应用一个技巧。
但首先我要指出的是,这非常容易,例如7-Zip http://www.7-zip.org's 7zCon.sfx
模块(如果您所需要做的就是将存档解压到当前目录,则不问任何问题)。因此,您可能只想尝试 IExpress 以外的其他方法。
无论如何,IExpress 的问题在于,当时我们安装程序运行后,我们不再位于原始存档的目录中;当前目录现在类似于%temp%\IXP000.TMP
。所以我们需要找到父进程的目录——有点痛苦。一旦知道了,我们就可以xcopy
将存档的内容复制到目标文件夹。
在 VBScript 中,它看起来像这样:
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
Your 安装程序那么将是,例如:wscript extractToOriginalLocation.vbs //B
.
(受到以下问题的回答的启发这个问题 https://stackoverflow.com/questions/8296037/find-my-own-process-id-in-vbscript.)