Skip to content
⌘ NSIS Forum Archive

Replace word

4 posts

ggroup#

Replace word

hi
How can the following command, the "$R0" to replace my constant, that is precisely the word "$R0" just be replaced.

FileWrite $R4 "IntCmp $R1 $R0 equel less more$\r$\n"

----------------
I want the word "$R0" is precisely in these replaced. After compiling the output in this field:

IntCmp 11212 equel less more 11212 instead of the $R1 value is replaced, but instead of $R0 is empty, the variable is not read! But I'd just replaced its $R0
----------------

!include MUI.nsh 
InstallButtonText 'Restore backup'
Name '*Updater-NOD32 2014-Google Cafe*'
OutFile 'C:\Users\GOOGLE~1\AppData\Local\Temp\backup.exe'
InstallDir 'C:\Program Files (x86)\KiLEr Group'
BrandingText 'Powered By KiLEr Group (Google Cafe)'
!define MUI_ABORTWARNING
!define /utcdate NOW '%H-%M-%S %d %b, %Y'
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP '.\banner.bmp' ; optional
SetDateSave on
AllowSkipFiles on
SetOverwrite on
ShowInstDetails nevershow
XPStyle on
AutoCloseWindow true
!insertmacro MUI_PAGE_INSTFILES
!include 'nsProcess.nsh'
ICON "restor-backuper.ico"
Function verscan
SetRegView 32
ReadRegStr $R0 HKLM 'SOFTWARE\ESET\ESET Security\CurrentVersion\Info' 'ScannerVersion'
ReadRegStr $R1 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'InstallDir'
ReadRegStr $R2 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'AppDataDir'
ReadRegStr $R3 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'DataDir'
ReadRegStr $R4 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'ScannerVersionId'
SetRegView 64
ReadRegStr $R0 HKLM 'SOFTWARE\ESET\ESET Security\CurrentVersion\Info' 'ScannerVersion'
ReadRegStr $R1 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'InstallDir'
ReadRegStr $R2 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'AppDataDir'
ReadRegStr $R3 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'DataDir'
ReadRegStr $R4 HKLM 'SOFTWARE\Eset\ESET Security\CurrentVersion\Info' 'ScannerVersionId'
FunctionEnd
Var checkupdate
Function checkupdate
call verscan
IntCmp 9516 $R4 equel less more
equel:
MessageBox MB_YESNO ' تاريخ اپديت اين پكيج با تاريخ اپديت انتي ويروس شما برابر است آيا تمايل به نصب مجدد آن داريد؟' IDYES more IDNO exit
Quit
less:
MessageBox MB_YESNO ' تاريخ اپديت اين پكيج از تاريخ اپديت انتي ويروس شما قديمي تر است آيا تمايل به جايگزيني اين اپديت داريد؟' IDYES more IDNO exit
exit:
Quit
more:
FunctionEnd
Var chkuser
Function chkuser
FileOpen $2 '$SYSDIR\checkuser.txt' w
FileClose $2
IfFileExists '$SYSDIR\checkuser.txt' admin limit
limit:
MessageBox MB_ICONSTOP|MB_RIGHT 'كاربري شما محدود است و امكان آپديت سازي آنتي ويروس شما وجود ندارد لطفا با كاربري مدير وارد شويد'
Quit
admin:
Delete /REBOOTOK '$SYSDIR\checkuser.txt'
FunctionEnd
Section
SetDetailsPrint none
call chkuser
call checkupdate
call verscan
SetOutPath '$R2\Updfiles\'
File /r 'C:\ProgramData\ESET\ESET NOD32 Antivirus\\Updfiles\*.nup'
SetOutPath '$R2\Updfiles\'
File /r 'C:\ProgramData\ESET\ESET NOD32 Antivirus\\Updfiles\*.ver'
CreateDirectory '$TEMP\update-nod\dat\'
SetOutPath '$TEMP\update-nod\dat\'
File /r 'C:\Program Files\ESET\ESET NOD32 Antivirus\\*.dat'
SetOutPath '$TEMP\update-nod\'
File /r 'C:\Users\GOOGLE~1\AppData\Local\Temp\update-nod\IRWIT-Updater.exe'
ShowWindow $HWNDPARENT ${{SW_HIDE}}'
ExecWait '$TEMP\update-nod\IRWIT-Updater.exe'
end:
RMDir /r /REBOOTOK '$TEMP\tempelate'
RMDir /r /REBOOTOK '$TEMP\NSIS'
RMDir /r /REBOOTOK '$TEMP\update-nod\dat\'
Delete /REBOOTOK $TEMP\backup.exe
Delete /REBOOTOK $TEMP\Updater-Nod32-$R0.exe
SectionEnd
code or example plz...
Anders#
I don't understand the question.

You should check for admin with the userinfo plugin and not the hack you are using.

I see several strange things in your script, are you getting compiler warnings?

I assume nod32 has a updater already so why do you need to mess with it? This does not smell right to me...
ggroup#
This code:


;ExperienceUI for NSIS
;Basic Example Script
;Written by X-KiLEr Group!
;--------------------------------

SetCompress force

# Included files
!include WinMessages.nsh
!include Sections.nsh
!include x64.nsh
!include MUI2.nsh
!include TextFunc.nsh

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

;Name and file
Name "Backup Offline NOD32 v2"
OutFile "Backuper.exe"

BrandingText "Powered By X-KiLEr Group **Google Cafe!**"

RequestExecutionLevel highest ; << Required, you cannot use admin!
;--------------------------------

;Interface Settings
# General Symbol Definitions
!define VERSION v2
!define COMPANY "X-KiLEr Group"
!define URL alpha-vpn.com

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

# MUI Settings
!insertmacro LineFind
;--------------------------------
;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

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

# Installer attributes
CRCCheck on
ShowInstDetails show
VIProductVersion 2.0.5.0
VIAddVersionKey ProductName "Backuper Offline NOD32"
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
VIAddVersionKey CompanyWebsite "${URL}"
VIAddVersionKey FileVersion "${VERSION}"
VIAddVersionKey FileDescription "Backuper Offline NOD32"
VIAddVersionKey LegalCopyright "By X-KiLEr Group v2 {Google Cafe!}"

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

;Languages

!insertmacro MUI_LANGUAGE English

;--------------------------------
!define ConfigWrite

;Installer Sections

Function Replace
SetRegView 32
ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" ScannerVersionId

SetRegView 64
ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" ScannerVersionId

FunctionEnd

Function Change



FunctionEnd

;[Functions] You create Line Replace Functions for each line
Function LineFindCallback
call Change
FileWrite $R4 " Var checkupdate $\r$\n"
FileWrite $R4 "Function checkupdate$\r$\n"
FileWrite $R4 " call verscan$\r$\n"
FileWrite $R4 "IntCmp $R1 $R0 equel less more$\r$\n" ======== >>>>>>> HERE $R0 ....I just got to be replaced.
FileWrite $R4 " MessageBox MB_YESNO ' تاريخ اپديت اين پكيج با تاريخ اپديت انتي ويروس شما برابر است آيا تمايل به نصب مجدد آن داريد؟' IDYES more IDNO exit$\r$\n"
FileWrite $R4 " Quit$\r$\n"
FileWrite $R4 "less:$\r$\n"
FileWrite $R4 " MessageBox MB_YESNO ' تاريخ اپديت اين پكيج از تاريخ اپديت انتي ويروس شما قديمي تر است آيا تمايل به جايگزيني اين اپديت داريد؟' IDYES more IDNO exit$\r$\n"
FileWrite $R4 "exit:$\r$\n"
FileWrite $R4 " Quit$\r$\n"
FileWrite $R4 "more:$\r$\n"
FileWrite $R4 " FunctionEnd$\r$\n"
Push $0
FunctionEnd


;[Sections] You call function for specific line in specific file
;Input and Output file can be same or different
;If Output file name is different (new file is created)
;then every next LineFind call should take Previous Output file as Input file

Section "Replace" Section

call Replace
SectionIn 1 +2
${LineFind} "D:\Restore.nsi" "D:\Google\Restore.nsi" "83" "LineFindCallback"
IfErrors 0 +2
SectionEnd

Section "Backup" SecDummy

SetRegView 32
ReadRegStr $1 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" InstallDir
ReadRegStr $2 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" AppDataDir
ReadRegStr $6 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" ScannerVersion

SetRegView 64
ReadRegStr $1 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" InstallDir
ReadRegStr $2 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" AppDataDir
ReadRegStr $6 HKEY_LOCAL_MACHINE "SOFTWARE\ESET\ESET Security\CurrentVersion\Info" ScannerVersion

SetOverwrite on
SetOutPath $PROGRAMFILES\Google
SetOverwrite on
File /r d:\Google\*

CopyFiles /SILENT "$1*.dat" "c:\Google Cafe\backup\ESET"

CopyFiles /SILENT "$2updfiles\*.*" "c:\Google Cafe\backup\Updfiles"

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

ExecWait "$PROGRAMFILES\Google\makeupdater.exe"

SetOverwrite on
CreateDirectory "$DESKTOP\Google Cafe"

CopyFiles /SILENT "$PROGRAMFILES\Google\ESET NOD32 v4.jpg" "$DESKTOP\Google Cafe\ESET NOD32 v4.jpg"
CopyFiles /SILENT "$PROGRAMFILES\Google\ESET NOD32 v5.jpg" "$DESKTOP\Google Cafe\ESET NOD32 v6-7-8.jpg"

SetOverwrite on
Rename $PROGRAMFILES\Google\Restore.exe "$DESKTOP\Google Cafe\$6.exe"

RMDir /r "c:\Google Cafe\*.*"
RMDir /r /REBOOTOK "$PROGRAMFILES\Google\*.*"
RMDir /r /REBOOTOK "$PROGRAMFILES\Google"

Quit

SectionEnd


# Installer functions
Function .onInit

InitPluginsDir

FunctionEnd

;--------------------------------
Anders#
If you want to escape a $ you must use $$: "$$R1". If that is not what you are asking then I cannot help because I don't understand what you are trying to do with this code...