| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  | ; example2.nsi | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | ; This script is based on example1.nsi, but it remember the directory,  | 
					
						
							|  |  |  | ; has uninstall support and (optionally) installs start menu shortcuts. | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | ; It will install example2.nsi into a directory that the user selects, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-31 01:25:39 +00:00
										 |  |  | !include LogicLib.nsh | 
					
						
							|  |  |  | !include "DotNET.nsh" | 
					
						
							|  |  |  | #define DOTNET_VERSION "2.0" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  | ;-------------------------------- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ; The name of the installer | 
					
						
							|  |  |  | Name "Embroidery Reader" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ; The file to write | 
					
						
							| 
									
										
										
										
											2011-02-13 19:39:49 +00:00
										 |  |  | OutFile "embroideryReadervvv-setup.exe" | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-03 21:05:41 +00:00
										 |  |  | ; Request admin privileges | 
					
						
							|  |  |  | RequestExecutionLevel admin | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  | ; The default installation directory | 
					
						
							|  |  |  | InstallDir "$PROGRAMFILES\Embroidery Reader" | 
					
						
							|  |  |  | ; Registry key to check for directory (so if you install again, it will  | 
					
						
							|  |  |  | ; overwrite the old one automatically) | 
					
						
							|  |  |  | InstallDirRegKey HKLM "Software\Embroidery Reader" "Install_Dir" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ;-------------------------------- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ; Pages | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Page components | 
					
						
							|  |  |  | Page directory | 
					
						
							|  |  |  | Page instfiles | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | UninstPage uninstConfirm | 
					
						
							|  |  |  | UninstPage instfiles | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ;-------------------------------- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ; The stuff to install | 
					
						
							| 
									
										
										
										
											2011-02-13 19:39:49 +00:00
										 |  |  | Section "Embroidery Reader (required)" | 
					
						
							| 
									
										
										
										
											2013-12-03 21:05:41 +00:00
										 |  |  |   # call userInfo plugin to get user info.  The plugin puts the result in the stack | 
					
						
							|  |  |  |   userInfo::getAccountType | 
					
						
							|  |  |  |     | 
					
						
							|  |  |  |   # pop the result from the stack into $0 | 
					
						
							|  |  |  |   pop $0 | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |   # compare the result with the string "Admin" to see if the user is admin. | 
					
						
							|  |  |  |   # If match, jump 3 lines down. | 
					
						
							|  |  |  |   strCmp $0 "Admin" +3 | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |   # if there is not a match, print message and return | 
					
						
							|  |  |  |   messageBox MB_OK "Embroidery Reader requires administrator privileges to install." | 
					
						
							|  |  |  |   return | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-03 21:05:41 +00:00
										 |  |  |   SetShellVarContext all | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |   SectionIn RO | 
					
						
							| 
									
										
										
										
											2008-01-31 01:25:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   ;check for .net 2 | 
					
						
							|  |  |  |   !insertmacro CheckDotNet "2.0" | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   ; Set output path to the installation directory. | 
					
						
							|  |  |  |   SetOutPath $INSTDIR | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   ; Put file there | 
					
						
							| 
									
										
										
										
											2011-02-13 19:39:49 +00:00
										 |  |  |   File "embroideryReader.exe" | 
					
						
							|  |  |  |   File "IniFile.dll" | 
					
						
							|  |  |  |   File "PesFile.dll" | 
					
						
							|  |  |  |   File "UpdateCheck.dll" | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   ; Write the installation path into the registry | 
					
						
							|  |  |  |   WriteRegStr HKLM "SOFTWARE\Embroidery Reader" "Install_Dir" "$INSTDIR" | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   ; Write the uninstall keys for Windows | 
					
						
							|  |  |  |   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Embroidery Reader" "DisplayName" "Embroidery Reader" | 
					
						
							|  |  |  |   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Embroidery Reader" "UninstallString" '"$INSTDIR\uninstall.exe"' | 
					
						
							|  |  |  |   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Embroidery Reader" "NoModify" 1 | 
					
						
							|  |  |  |   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Embroidery Reader" "NoRepair" 1 | 
					
						
							|  |  |  |   WriteUninstaller "uninstall.exe" | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | SectionEnd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ; Optional section (can be disabled by the user) | 
					
						
							|  |  |  | Section "Start Menu Shortcuts" | 
					
						
							| 
									
										
										
										
											2013-12-03 21:05:41 +00:00
										 |  |  |   SetShellVarContext all | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |   CreateDirectory "$SMPROGRAMS\Embroidery Reader" | 
					
						
							|  |  |  |   CreateShortCut "$SMPROGRAMS\Embroidery Reader\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 | 
					
						
							|  |  |  |   CreateShortCut "$SMPROGRAMS\Embroidery Reader\Embroidery Reader.lnk" "$INSTDIR\embroideryReader.exe" "" "$INSTDIR\embroideryReader.exe" 0 | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | SectionEnd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Section "Associate with .PES files" | 
					
						
							| 
									
										
										
										
											2013-12-03 21:05:41 +00:00
										 |  |  |   SetShellVarContext all | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |   ; back up old value of .pes | 
					
						
							|  |  |  | !define Index "Line${__LINE__}" | 
					
						
							|  |  |  |   ReadRegStr $1 HKCR ".pes" "" | 
					
						
							|  |  |  |   StrCmp $1 "" "${Index}-NoBackup" | 
					
						
							|  |  |  |     StrCmp $1 "EmbroideryDesign" "${Index}-NoBackup" | 
					
						
							|  |  |  |     WriteRegStr HKCR ".pes" "backup_val" $1 | 
					
						
							|  |  |  | "${Index}-NoBackup:" | 
					
						
							|  |  |  |   WriteRegStr HKCR ".pes" "" "EmbroideryDesign" | 
					
						
							|  |  |  |   ReadRegStr $0 HKCR "EmbroideryDesign" "" | 
					
						
							|  |  |  |   StrCmp $0 "" 0 "${Index}-Skip" | 
					
						
							|  |  |  | 	WriteRegStr HKCR "EmbroideryDesign" "" "Embroidery Design File" | 
					
						
							|  |  |  | 	WriteRegStr HKCR "EmbroideryDesign\shell" "" "open" | 
					
						
							|  |  |  | 	WriteRegStr HKCR "EmbroideryDesign\DefaultIcon" "" "$INSTDIR\embroideryReader.exe,0" | 
					
						
							|  |  |  | "${Index}-Skip:" | 
					
						
							|  |  |  |   WriteRegStr HKCR "EmbroideryDesign\shell\open\command" "" '$INSTDIR\embroideryReader.exe "%1"' | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |   System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)' | 
					
						
							|  |  |  | !undef Index | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SectionEnd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ;-------------------------------- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ; Uninstaller | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Section "Uninstall" | 
					
						
							| 
									
										
										
										
											2013-12-03 21:05:41 +00:00
										 |  |  |   SetShellVarContext all | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  | ;start of restore script | 
					
						
							|  |  |  | !define Index "Line${__LINE__}" | 
					
						
							|  |  |  |   ReadRegStr $1 HKCR ".pes" "" | 
					
						
							|  |  |  |   StrCmp $1 "EmbroideryDesign" 0 "${Index}-NoOwn" ; only do this if we own it | 
					
						
							|  |  |  |     ReadRegStr $1 HKCR ".pes" "backup_val" | 
					
						
							|  |  |  |     StrCmp $1 "" 0 "${Index}-Restore" ; if backup="" then delete the whole key | 
					
						
							|  |  |  |       DeleteRegKey HKCR ".pes" | 
					
						
							|  |  |  |     Goto "${Index}-NoOwn" | 
					
						
							|  |  |  | "${Index}-Restore:" | 
					
						
							|  |  |  |       WriteRegStr HKCR ".pes" "" $1 | 
					
						
							|  |  |  |       DeleteRegValue HKCR ".pes" "backup_val" | 
					
						
							|  |  |  |     | 
					
						
							|  |  |  |     DeleteRegKey HKCR "EmbroideryDesign" ;Delete key with association settings | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |     System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)' | 
					
						
							|  |  |  | "${Index}-NoOwn:" | 
					
						
							|  |  |  | !undef Index | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ; Remove registry keys | 
					
						
							|  |  |  |   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Embroidery Reader" | 
					
						
							|  |  |  |   DeleteRegKey HKLM "SOFTWARE\Embroidery Reader" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-22 04:09:39 +00:00
										 |  |  |   ; Remove obsolete files from previous versions, if they exist | 
					
						
							|  |  |  |   Delete $INSTDIR\UpdateInstaller.exe | 
					
						
							| 
									
										
										
										
											2007-09-22 04:11:19 +00:00
										 |  |  |   RMDir "$INSTDIR\update" | 
					
						
							| 
									
										
										
										
											2011-02-13 19:39:49 +00:00
										 |  |  |   Delete $INSTDIR\nc_settings.dll | 
					
						
							|  |  |  |   Delete $INSTDIR\embroideryreader.ini | 
					
						
							|  |  |  |   Delete $INSTDIR\nc_Updater.dll | 
					
						
							| 
									
										
										
										
											2007-09-22 04:09:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |   ; Remove shortcuts, if any | 
					
						
							| 
									
										
										
										
											2013-12-03 20:33:41 +00:00
										 |  |  |   Delete "$SMPROGRAMS\Embroidery Reader\Uninstall.lnk" | 
					
						
							|  |  |  |   Delete "$SMPROGRAMS\Embroidery Reader\Embroidery Reader.lnk" | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |   RMDir "$SMPROGRAMS\Embroidery Reader" | 
					
						
							| 
									
										
										
										
											2013-12-03 21:05:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   ; Remove files and uninstaller | 
					
						
							|  |  |  |   Delete $INSTDIR\embroideryReader.exe | 
					
						
							|  |  |  |   Delete $INSTDIR\PesFile.dll | 
					
						
							|  |  |  |   Delete $INSTDIR\UpdateCheck.dll | 
					
						
							|  |  |  |   Delete $INSTDIR\IniFile.dll | 
					
						
							|  |  |  |   Delete $INSTDIR\uninstall.exe | 
					
						
							| 
									
										
										
										
											2007-08-08 03:39:41 +00:00
										 |  |  |   RMDir "$INSTDIR" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SectionEnd |