Archive: Execute script after reboot automatically


Execute script after reboot automatically
Hi,

I have to execute a part of the installation after a reboot. That means, some files are installed, the system is rebooted and after the reboot the installation process has to be continued.

So my question is: how can I define a NSIS-script that is executed after rebooting?

Oxyyy


You can add your installer in RunOnce key of regestry. Execute your installer with parameter which can tell you about computer's restart.


Or even write a registry key to tell your installer that the PC was just rebooted (remember to remove it afterwards!)

-Stu


Originally posted by glory_man
You can add your installer in RunOnce key of regestry. Execute your installer with parameter which can tell you about computer's restart.
That sounds good but thereI have the problem that the installer can be located somewhere on a network drive that is no longer available after restarting. So it would be necessary to copy the installer itself to e.g. TMP. But is this possible?

Try CopyFiles on itself. If this doesn't work (I doubt it will) then you need to write another installer to do it. This other installer will contain the following:

OutFile "CopyInstaller.exe"

Function .onInit
Sleep 1000 #Need to wait a bit until installer closes.
Call GetParameters
Pop $R0
CopyFiles $R0 "$TEMP\setupfile.exe"
Abort
FunctionEnd

Section
SectionEnd


So you should include this file as any other file, extract it to $TEMP and execute it from there with "$INSTDIR" as the parameter. Ideally the installer should Exec it and then Quit immediately. Also you need the GetParameters function in the script (which you can grab in the docs under Useful Scripts).

-Stu