Search code examples
directorynsis

Nsis - changing installation directory


Currently I am in my installing directory say c:\Program File\My installer.I have to execute a demo.bat file that is stored at some other location say c:\Program Files\Temp\example.bat,which I have to go at that location and execute coz my example.bat has some support files that are only stored in Temp folder.

My question is how can I change my installing directory to some other directory, execute demo.bat file and come back to my original installing directory while writing an nsis script?


Solution

  • When talking about "installing directory", I assume you mean current/working directory in the context of a batch file.

    push $outdir ;save original path
    SetOutpath "$programfiles\temp" ;set currect directory
    nsExec::Exec "example.bat"
    pop $outdir
    SetOutpath $outdir ;restore
    

    There are several ways to execute a batch file (Expand %comspec% and pass it to Exec/ExecWait, or use one of the exec plugins (nsExec,ExecDos,ExecCmd))