Old 4th October 2022, 11:08   #1
Mike-Sean
Junior Member
 
Join Date: Sep 2022
Posts: 7
Restart machine and continue

Hi,

I have installer.nsi File where i call multiple .bat scripts.
So i have requirement like after installing some drivers i need to restart the system and after restart i need to continue from the step where it is stopped, i don't want to stop from beginning.

Is there any way i can do it from Nsi scripts? I have to continue from the scripts where it stopped not from the beginning of NSI script.
Mike-Sean is offline   Reply With Quote
Old 4th October 2022, 13:01   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,538
Ideally you would just configure everything and then reboot but if you must...

You need to structure your script into multiple Sections. When you get to the reboot point, write a RunOnce registry entry and then reboot. After rebooting, detect this incomplete state and use Sections.nsh to disable the Sections you already completed. You also have to skip the pages before InstFiles.

Depending on what you are doing, it might be easier to create a helper .exe to perform the post reboot actions instead.

Caveats: RunOnce will not complete until an admin logs in.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th October 2022, 13:53   #3
Mike-Sean
Junior Member
 
Join Date: Sep 2022
Posts: 7
Hi,

Thanks for your reply. I have a sample script like:
!include "MUI.nsh"
; include first in order to enable LogicLib support
!include "LogicLib.nsh"
!include "WinVer.nsh"

!addplugindir "Plugins\"

RequestExecutionLevel user
ShowInstDetails show

Section

SetOutPath $INSTDIR\${APPLICATION_DIR}
ExpandEnvStrings $0 %COMSPEC%
nsExec::ExecToStack '"C:\path-tobatch-file\commands.bat"'

nsExec::ExecToStack '"C:\path-tobatch-file\Test.bat"'

nsExec::ExecToStack 'C:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe -inputformat none -ExecutionPolicy RemoteSigned -File ""$EXEDIR\SysInfo.ps1""'
Pop $R0 # return value/error/timeout
Pop $R1 # printed text,

SectionEnd


Here after commands.bat the system will restart and after restart the nsi script should start from Test.bat onwards.
Can u give me sample script to handle this since am new to NSI scripting.
Mike-Sean is offline   Reply With Quote
Old 4th October 2022, 23:17   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,538
I said multiple sections and you are not even trying. You are also missing some Pop's in that code...

Try https://nsis.sourceforge.io/Reboot_and_Continue

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
reboot, runonce

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump