Iexpress - extraction path

放肆的年华 提交于 2019-12-08 08:15:42

问题


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?


回答1:


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

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.

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.

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

Your install program would then be, eg: wscript extractToOriginalLocation.vbs //B.

(Inspired somewhat by the answer to this question.)



来源:https://stackoverflow.com/questions/13534699/iexpress-extraction-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!