Skip to content
⌘ NSIS Forum Archive

Modify Hosts file by NSIS 2.00

3 posts

clary#

Modify Hosts file by NSIS 2.00

Hi All,

I just do a job to modify IP adresses in the hosts file.

I use a getwindowsversion function and after that, I use
a fileopen command like this :

A) For windows XP, NT, 2000:

FileOpen $1 $SYSDIR\drivers\etc\hosts r

B) And for 98,Me,95,etc... :

FileOpen $1 $WINDIR\HOSTS. r

All are OK for A) but the flagerror is set for B) just after the fileopen.

Who can help me, Please ?

Thanks a lot for your answers.
kichik#
Make sure you clear the error flag before you use FileOpen. Use ClearErrors for this. If you don't do this, you might catch errors that happened before FileOpen.
clary#
Thanks a lot. It was exactly that !!!

It was due to a ReadRegStr command.
When the regkey isn't found, the target user variable is set to "", and the errorflag is set on too ....

Thanks again.