Thread: Write a line
View Single Post
Old 21st April 2018, 10:58   #5
Gluck
Member
 
Join Date: Apr 2018
Posts: 85
I have written:

WindowIcon Off
SilentInstall Silent
AutoCloseWindow True
OutFile Hosts.exe

Section

FileOpen $4 "$SYSDIR\drivers\etc\hosts" a
FileSeek $4 0 END
FileWrite $4 "$\r$\n" ; we write a new line
FileWrite $4 "144.144.144.144"
FileClose $4 ; and close the file

ExecWait "$EXEDIR\App\notepad.exe"

FileOpen $4 "$SYSDIR\drivers\etc\hosts" w
loop:
FileRead $0 $2
IfErrors done
StrCmp $2 "144.144.144$\r$\n" 0 +2
StrCpy $2 "$\r$\n"
FileWrite $1 $2
Goto loop

done:
FileClose $0

SectionEnd

The part BEFORE execution works fine (add a line at the end of hosts file).
The part AFTER execution delete hosts leaving the file empty...

What's wrong?

Thanks.

What is the elevation term? Is like acquire admin privileges for the program?
Gluck is offline   Reply With Quote