All pastes #754238 Raw Edit

Mine

public text v1 · immutable
#754238 ·published 2007-10-29 21:33 UTC
rendered paste body
!include nsDialogs.nsh
!include LogicLib.nsh
!include "MUI.nsh"

Name "Primary Email Notify"
!insertmacro MUI_PAGE_WELCOME
Page custom nsDialogsPage

Var EDIT
Var username

Function nsDialogsPage

	nsDialogs::Create /NOUNLOAD 1018
	Pop $0

	GetFunctionAddress $0 OnBack
	nsDialogs::OnBack /NOUNLOAD $0

	${NSD_CreateText} 100 35 100% 12u john.smith
;${NSD_GetText} 100 35 100% 12u john.smith
	Pop $EDIT
GetFunctionAddress $0 OnTrustedConnection
${NSD_GetText} $0 $username 
;nsDialogs::OnClick /NOUNLOAD $TRUSTEDCONNECTION $0

	${NSD_CreateLabel} 0 35 75% 40u "firstname.surname: "
	Pop $0

	${NSD_CreateLabel} 0 40u 75% 40u "- Type your firstname.surname or username above.  ie john.smith"
	Pop $0
	nsDialogs::Show


FunctionEnd


Function OnTrustedConnection
${NSD_GetText} $0 $username 
FunctionEnd

Function OnBack

	MessageBox MB_YESNO "are you sure?" IDYES +2
	Abort

FunctionEnd


Section
MessageBox MB_OK $username
SectionEnd

  ShowInstDetails show
;--------------------------------
;Pages

 !insertmacro MUI_PAGE_INSTFILES
  
    # These indented statements modify settings for MUI_PAGE_FINISH
;    !define MUI_FINISHPAGE_NOAUTOCLOSE
;    !define MUI_FINISHPAGE_RUN
;    !define MUI_FINISHPAGE_RUN_NOTCHECKED
;    !define MUI_FINISHPAGE_RUN_TEXT "Start a shortcut"
;    !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
;    !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
;    !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\readme.txt
;  !insertmacro MUI_PAGE_FINISH
 
;Languages
!insertmacro MUI_LANGUAGE "English"
 
;--------------------------------
# No components page, so this is anonymous

;--------------------------------


; This Function will display "My Documents" Folder path.
; Now it suppose to work with multiple users.
; Created by Joel
 
;Name "Get My Documents Path"
OutFile "GetMyDocPath.exe"
 
Function "GetMyDocs"
  ReadRegStr $0 HKCU \
             "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" \
             Personal
FunctionEnd
 
Function .onInit
  Call "GetMyDocs"
StrCpy $instdir $0
;  MessageBox MB_OK|MB_ICONINFORMATION $0
FunctionEnd

 
Section -Ghost
  ; Nothing here, :p
Sectionend


!ifdef HAVE_UPX
!packhdr tmp.dat "upx\upx -9 tmp.dat"
!endif
!ifdef NOCOMPRESS
SetCompress off
!endif

;--------------------------------

;Name "Primary Technology Software"
Caption "Primary Email Notify Installer"
Icon "${NSISDIR}\Contrib\Graphics\Icons\nsis1-install.ico"
OutFile "primaryemail_notify_setup.exe"

SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal
; BGGradient 000000 689bca FFFFFF
InstallColors FFFFFF 000030
XPStyle on
BrandingText "Primary Technology Installer v1.00"
InstallDir $0
;InstallDir "$0"
InstallDirRegKey HKLM "Software\PrimaryTechnology" ""

CheckBitmap "${NSISDIR}\Contrib\Graphics\Checks\classic-cross.bmp"

LicenseText "License Agreement"
LicenseData "setup.nsi"


UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

!ifndef NOINSTTYPES ; only if not defined
  InstType "Primary Email Notify"
!endif

AutoCloseWindow false
ShowInstDetails show

;--------------------------------


Section "" ; empty string makes it hidden, so would starting with -

WriteRegStr HKLM SOFTWARE\PrimaryTechnology "Install_Dir" "$INSTDIR"

; write uninstall strings
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PrimaryTechnology" "DisplayName" "PrimaryTechnology (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PrimaryTechnology" "UninstallString" '"$INSTDIR\bt-uninst.exe"'

;SetOutPath $INSTDIR

WriteUninstaller "bt-uninst.exe"
Nop ; for fun

SectionEnd

Section "Primary Email Notify Installer"
SectionIn 1

File /r files\*.*

Call "GetMyDocs"
;  MessageBox MB_OK|MB_ICONINFORMATION $0
SetOutPath "$0"

;SetOutPath "c:\documents and settings\administrator\my documents"
File files\config.xml
;Call AdvReplaceInFile
ExecShell "" "c:\documents and settings\administrator\my documents\owanotify.exe"

SectionEnd



Function AdvReplaceInFile
Exch $0 ;file to replace in
Exch
Exch $1 ;number to replace after
Exch
Exch 2
Exch $2 ;replace and onwards
Exch 2
Exch 3
Exch $3 ;replace with
Exch 3
Exch 4
Exch $4 ;to replace
Exch 4
Push $5 ;minus count
Push $6 ;universal
Push $7 ;end string
Push $8 ;left string
Push $9 ;right string
Push $R0 ;file1
Push $R1 ;file2
Push $R2 ;read
Push $R3 ;universal
Push $R4 ;count (onwards)
Push $R5 ;count (after)
Push $R6 ;temp file name
 
  GetTempFileName $R6
  FileOpen $R1 $0 r ;file to search in
  FileOpen $R0 $R6 w ;temp file
   StrLen $R3 $4
   StrCpy $R4 -1
   StrCpy $R5 -1
 
loop_read:
 ClearErrors
 FileRead $R1 $R2 ;read line
 IfErrors exit
 
   StrCpy $5 0
   StrCpy $7 $R2
 
loop_filter:
   IntOp $5 $5 - 1
   StrCpy $6 $7 $R3 $5 ;search
   StrCmp $6 "" file_write2
   StrCmp $6 $4 0 loop_filter
 
StrCpy $8 $7 $5 ;left part
IntOp $6 $5 + $R3
IntCmp $6 0 is0 not0
is0:
StrCpy $9 ""
Goto done
not0:
StrCpy $9 $7 "" $6 ;right part
done:
StrCpy $7 $8$3$9 ;re-join
 
IntOp $R4 $R4 + 1
StrCmp $2 all file_write1
StrCmp $R4 $2 0 file_write2
IntOp $R4 $R4 - 1
 
IntOp $R5 $R5 + 1
StrCmp $1 all file_write1
StrCmp $R5 $1 0 file_write1
IntOp $R5 $R5 - 1
Goto file_write2
 
file_write1:
 FileWrite $R0 $7 ;write modified line
Goto loop_read
 
file_write2:
 FileWrite $R0 $R2 ;write unmodified line
Goto loop_read
 
exit:
  FileClose $R0
  FileClose $R1
 
   SetDetailsPrint none
  Delete $0
  Rename $R6 $0
  Delete $R6
   SetDetailsPrint both
 
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $0
Pop $1
Pop $2
Pop $3
Pop $4


Push ---username--- #text to be replaced
Push $username #replace with
Push all #replace all occurrences
Push all #replace all occurrences
Push "C:\documents and settings\administrator\my documents\config.xml" #file to replace in
 Call AdvReplaceInFile

Push https://exchange.primaryt.co.uk/exchange/---username---/inbox #text to be replaced
Push https://exchange.primaryt.co.uk/exchange/$username/inbox #replace with
Push all #replace all occurrences
Push all #replace all occurrences
Push "C:\documents and settings\administrator\my documents\config.xml" #file to replace in

 Call AdvReplaceInFile

FunctionEnd



;--------------------------------

; Uninstaller

UninstallText "This will uninstall Primary Technology Software. Hit next to continue."
UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\nsis1-uninstall.ico"

Section "Uninstall"

  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PrimaryTechnology"
  DeleteRegKey HKLM "SOFTWARE\PrimaryTechnology"
;  Delete "$INSTDIR\silent.nsi"
  Delete "$INSTDIR\LogicLib.nsi"
  Delete "$INSTDIR\bt-uninst.exe"
  Delete "$INSTDIR\test.ini"
  Delete "$SMPROGRAMS\Big NSIS Test\*.*"
  RMDir "$SMPROGRAMS\BiG NSIS Test"
  
  MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to remove the directory $INSTDIR\cpdest?" IDNO NoDelete
    Delete "$INSTDIR\cpdest\*.*"
    RMDir "$INSTDIR\cpdest" ; skipped if no
  NoDelete:
  
  RMDir "$INSTDIR"

  IfFileExists "$INSTDIR" 0 NoErrorMsg
    MessageBox MB_OK "Note: $INSTDIR could not be removed!" IDOK 0 ; skipped if file doesn't exist
  NoErrorMsg:

SectionEnd