目前我在我的安装目录中说 c:\Program File\My installer.我必须执行一个存储在其他位置的 demo.bat 文件说 c:\Program Files\Temp\example.bat,我必须这样做去那个位置并执行因为我的 example.bat 有一些只存储在 Temp 文件夹中的支持文件。
我的问题是如何在编写 nsis 脚本时将我的安装目录更改为其他目录,执行 demo.bat 文件并返回到我原来的安装目录?
在谈论“安装目录”时,我假设您指的是批处理文件上下文中的当前/工作目录。
push $outdir ;save original path
SetOutpath "$programfiles\temp" ;set currect directory
nsExec::Exec "example.bat"
pop $outdir
SetOutpath $outdir ;restore
有几种方法可以执行批处理文件(展开 %comspec% 并将其传递给 Exec/ExecWait,或使用其中一个 exec 插件(nsExec、ExecDos、ExecCmd))