Index: mswin32/winpcap/winpcap-nmap.nsi =================================================================== --- mswin32/winpcap/winpcap-nmap.nsi (revision 16418) +++ mswin32/winpcap/winpcap-nmap.nsi (working copy) @@ -252,8 +252,9 @@ Function doOptions ReadINIStr $0 "$PLUGINSDIR\options.ini" "Field 1" "State" - StrCmp $0 "0" do_options_end + StrCmp $0 "0" do_options_next WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\NPF" "Start" 2 + do_options_next: ReadINIStr $0 "$PLUGINSDIR\options.ini" "Field 2" "State" StrCmp $0 "0" do_options_end nsExec::Exec "net start npf" @@ -318,6 +319,16 @@ ; The stuff to install Section "WinPcap" SecWinPcap + ; stop the service, in case it's still registered, so files can be + ; safely overwritten and the service can be deleted. + nsExec::Exec "net stop npf" + + ; NB: We may need to introduce a check here to ensure that NPF + ; has been stopped before we continue, otherwise we Sleep for a + ; while and try the check again. This might help prevent any race + ; conditions during a silent install (and potentially during the + ; slower GUI installation. + ; These x86 files are automatically redirected to the right place on x64 SetOutPath $SYSDIR File pthreadVC.dll @@ -383,13 +394,13 @@ npfdone: - ; stop the service, in case it's still registered, so it can be deleted - nsExec::Exec "net stop npf" - ; register the driver as a system service using Windows API calls ; this will work on Windows 2000 (that lacks sc.exe) and higher Call registerServiceAPI + ; Create the default NPF startup setting of 3 (SERVICE_DEMAND_START) + WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\NPF" "Start" 3 + ; automatically start the service if performing a silent install IfSilent auto_start skip_auto_start auto_start: