Skip to content

Commit

Permalink
Reapply clobbered commit
Browse files Browse the repository at this point in the history
The uninstaller in "/S" silent mode will wait for GUI applications to close themselves for at most 15 seconds, then terminate any unclosed to finish the uninstall.

Conflicts:
	installer/Npcap-for-nmap.nsi
  • Loading branch information
hsluoyz authored and bonsaiviking committed Jan 5, 2017
1 parent b922867 commit 064d2a3
Showing 1 changed file with 112 additions and 75 deletions.
187 changes: 112 additions & 75 deletions installer/Npcap-for-nmap.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,9 @@ ${!defineifexist} EV_CERT_EXISTS "C:\Insecure-EV.cer"
DetailPrint "Failed to create the npcap2 service for Win7, Win8 and Win10"
${IfNot} ${Silent}
MessageBox MB_OK "Failed to create the npcap2 service for Win7, Win8 and Win10. Please try installing Npcap again, or use the official Npcap installer from https://github.com/nmap/npcap/releases"
${EndIf}
${EndIf}
${EndIf}
${EndIf}
FunctionEnd

Function un.uninstall_win7_XXbit_driver
Expand Down Expand Up @@ -1522,85 +1522,122 @@ Section "Uninstall"
; Stop the driver service before we uninstall it
DetailPrint "Trying to stop the driver.."
Call un.stop_driver_service
ExecWait '"$INSTDIR\NPFInstall.exe" -n -d' $0
${If} $0 == "0"
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
MessageBox MB_OK "Failed to stop the driver. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
DetailPrint "Failed to stop the driver. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
Goto uninstall_fail
${EndIf}
${If} $ndis6_driver == "yes"
terminate_back_1:
ExecWait '"$INSTDIR\NPFInstall.exe" -n -d' $0
${If} $0 == "0"
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -n -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
DetailPrint "Failed to stop the driver. Please close programs: $1 which may be using Npcap and try again."
${IfNot} ${Silent}
MessageBox MB_YESNO "Failed to uninstall Npcap because it is in use by application(s): $1. You may choose the Yes button to terminate that software now, or hit No, close the software manually, and restart the Npcap uninstaller." IDYES terminate_retry_1 IDNO uninstall_fail
terminate_retry_1:
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc' $0
Goto terminate_back_1
${Else}
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc_polite' $0
ExecWait '"$INSTDIR\NPFInstall.exe" -n -d' $0
${EndIf}
${EndIf}
${EndIf}

; Remove "C:\Windows\System32\Npcap" from PATH
; Call un.clear_env_var

; Remove the files
; uninstall_win7_32bit
${If} $is_64bit == "no"
; delete the 32-bit DLLs and EXEs in System folder
StrCpy $cur_system_folder "System32"
Call un.remove_win7_XXbit_system_dlls
${If} $err_flag != ""
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
MessageBox MB_OK "Failed to delete: $err_flag. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
DetailPrint "Failed to delete: $err_flag. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
Goto uninstall_fail
${EndIf}

; delete the driver
Call un.remove_win7_driver

; delete the DLLs and EXEs in home folder
Call un.remove_win7_XXbit_home_dlls
; uninstall_win7_64bit
${Else}
; delete the 32-bit DLLs and EXEs in System folder
StrCpy $cur_system_folder "SysWOW64"
Call un.remove_win7_XXbit_system_dlls
${If} $err_flag != ""
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
MessageBox MB_OK "Failed to delete: $err_flag. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
DetailPrint "Failed to delete: $err_flag. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
Goto uninstall_fail
${EndIf}

; disable Wow64FsRedirection
System::Call kernel32::Wow64EnableWow64FsRedirection(i0)

; delete the 64-bit DLLs and EXEs in System folder
StrCpy $cur_system_folder "System32"
Call un.remove_win7_XXbit_system_dlls
${If} $err_flag != ""
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
MessageBox MB_OK "Failed to delete: $err_flag. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
DetailPrint "Failed to delete: $err_flag. Uninstall aborted. Please close programs: $1 which may be using Npcap and try again."
Goto uninstall_fail
${EndIf}

; delete the driver
Call un.remove_win7_driver

; re-enable Wow64FsRedirection
System::Call kernel32::Wow64EnableWow64FsRedirection(i1)

; delete the DLLs and EXEs in home folder
Call un.remove_win7_XXbit_home_dlls
${EndIf}
; uninstall_win7_32bit
${If} $is_64bit == "no"
; delete the 32-bit DLLs and EXEs in System folder
StrCpy $cur_system_folder "System32"
terminate_back_2:
Call un.remove_win7_XXbit_system_dlls
${If} $err_flag != ""
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -n -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
DetailPrint "Failed to delete: $err_flag. Please close programs: $1 which may be using Npcap and try again."
StrCpy $err_flag ""
${IfNot} ${Silent}
MessageBox MB_YESNO "Failed to uninstall Npcap because it is in use by application(s): $1. You may choose the Yes button to terminate that software now, or hit No, close the software manually, and restart the Npcap uninstaller." IDYES terminate_retry_2 IDNO uninstall_fail
terminate_retry_2:
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc' $0
Goto terminate_back_2
${Else}
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc_polite' $0
Call un.remove_win7_XXbit_system_dlls
${EndIf}
${EndIf}

; delete the driver
Call un.remove_win7_driver

; delete the DLLs and EXEs in home folder
Call un.remove_win7_XXbit_home_dlls
; uninstall_win7_64bit
${Else}
; delete the 32-bit DLLs and EXEs in System folder
StrCpy $cur_system_folder "SysWOW64"
terminate_back_3:
Call un.remove_win7_XXbit_system_dlls
${If} $err_flag != ""
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -n -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
DetailPrint "Failed to delete: $err_flag. Please close programs: $1 which may be using Npcap and try again."
StrCpy $err_flag ""
${IfNot} ${Silent}
MessageBox MB_YESNO "Failed to uninstall Npcap because it is in use by application(s): $1. You may choose the Yes button to terminate that software now, or hit No, close the software manually, and restart the Npcap uninstaller." IDYES terminate_retry_3 IDNO uninstall_fail
terminate_retry_3:
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc' $0
Goto terminate_back_3
${Else}
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc_polite' $0
Call un.remove_win7_XXbit_system_dlls
${EndIf}
${EndIf}

; disable Wow64FsRedirection
System::Call kernel32::Wow64EnableWow64FsRedirection(i0)

; delete the 64-bit DLLs and EXEs in System folder
StrCpy $cur_system_folder "System32"
terminate_back_4:
Call un.remove_win7_XXbit_system_dlls
${If} $err_flag != ""
; get the processes that are using Npcap
nsExec::ExecToStack '"$INSTDIR\NPFInstall.exe" -n -check_dll'
Pop $0
Pop $1
StrCpy $1 $1 -2
DetailPrint "Failed to delete: $err_flag. Please close programs: $1 which may be using Npcap and try again."
StrCpy $err_flag ""
${IfNot} ${Silent}
MessageBox MB_YESNO "Failed to uninstall Npcap because it is in use by application(s): $1. You may choose the Yes button to terminate that software now, or hit No, close the software manually, and restart the Npcap uninstaller." IDYES terminate_retry_4 IDNO uninstall_fail
terminate_retry_4:
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc' $0
Goto terminate_back_4
${Else}
ExecWait '"$INSTDIR\NPFInstall.exe" -n -kill_proc_polite' $0
Call un.remove_win7_XXbit_system_dlls
${EndIf}
${EndIf}

; delete the driver
Call un.remove_win7_driver

; re-enable Wow64FsRedirection
System::Call kernel32::Wow64EnableWow64FsRedirection(i1)

; delete the DLLs and EXEs in home folder
Call un.remove_win7_XXbit_home_dlls
${EndIf}

; Uninstall the driver
Call un.registerServiceAPI_win7
Expand Down

0 comments on commit 064d2a3

Please sign in to comment.