Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.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
Batch file 如何在不安装的情况下从安装程序复制文件_Batch File_Windows Installer_Nsis - Fatal编程技术网

Batch file 如何在不安装的情况下从安装程序复制文件

Batch file 如何在不安装的情况下从安装程序复制文件,batch-file,windows-installer,nsis,Batch File,Windows Installer,Nsis,我已经使用NSIS创建了安装程序 我有一个批处理文件,如果自动安装失败,它需要运行(安装程序检查是否有任何版本的软件已经存在,如果第一次卸载它) 如何从安装程序运行批处理文件而不安装它 NSIS并不真正关心您是否将文件解压缩到$InstDir或其他地方: !define UninstId "MyAppBlahBlah" !include LogicLib.nsh Function RunMyBatch InitPluginsDir SetOutPath $PluginsDir Fi

我已经使用NSIS创建了安装程序

我有一个批处理文件,如果自动安装失败,它需要运行(安装程序检查是否有任何版本的软件已经存在,如果第一次卸载它)


如何从安装程序运行批处理文件而不安装它

NSIS并不真正关心您是否将文件解压缩到
$InstDir
或其他地方:

!define UninstId "MyAppBlahBlah"
!include LogicLib.nsh

Function RunMyBatch
  InitPluginsDir
  SetOutPath $PluginsDir
  File "myfiles\mybatch.bat"
  StrCpy $0 "$SysDir\cmd.exe"
  IfFileExists $0 +2
    ExpandEnvStrings $0 "%COMSPEC%"
  nsExec::Exec '"$0" /C "$PluginsDir\mybatch.bat"'
  Pop $0 ; Exit code
  SetOutPath $Temp ; Don't hold lock on $PluginsDir
FunctionEnd

Function .onInit
  ReadRegStr $0 HKLM "Software\Software\Microsoft\Windows\CurrentVersion\Uninstall\${UninstId}" "UninstallString"
  ${If} $0 != ""
    !insertmacro UninstallExisting $0 $0 ; https://nsis.sourceforge.io/Auto-uninstall_old_before_installing_new
    ${If} $0 <> 0
      Call RunMyBatch ; Run batch if uninstall old failed
    ${EndIf}
  ${EndIf}
FunctionEnd

Function .onInstFailed
  Call RunMyBatch ; Run batch if install failed
FunctionEnd
!定义未输入的“MyAppBlahBlah”
!包括LogicLib.nsh
函数RunMyBatch
InitPluginsDir
SetOutPath$PluginsDir
文件“myfiles\mybatch.bat”
StrCpy$0“$SysDir\cmd.exe”
如果存在$0+2
ExpandEnvStrings$0“%COMSPEC%”
nsExec::Exec“$0”/C“$PluginsDir\mybatch.bat”
流行音乐0美元;出口代码
SetOutPath$Temp;不要锁定$PluginsDir
功能端
函数。onInit
ReadRegStr$0 HKLM“Software\Software\Microsoft\Windows\CurrentVersion\Uninstall\${UninstId}”卸载字符串
${If}$0!=""
!insertmacro卸载现有$0$0;https://nsis.sourceforge.io/Auto-uninstall_old_before_installing_new
${If}$0
调用RunMyBatch;如果卸载旧版本失败,请运行批处理
${EndIf}
${EndIf}
功能端
函数。OnInstall失败
调用RunMyBatch;如果安装失败,请运行批处理
功能端

很抱歉,您的问题离题了,您没有提供一个最小、完整和可验证的示例。尽管如此,您的问题是关于特定软件的使用,而不是编程。因此,您的建议是阅读软件的使用信息,然后在发布问题之前尝试实施您所了解的内容。“如果自动安装失败,则需要运行”您在这里指的是自动卸载吗?