LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to edit Windows host file

Hi,

 

I want to edit windows host file located in C:\Windows\System32\drivers\etc\host .But it shows permission error when I'm trying to do this. I tried with running as administrator also. Still I can edit networks file located in the same folder (C:\Windows\System32\drivers\etc\networks) with same security permissions as of host file . I can edit the host file by opening it in the notepad as administrator. Is there any other method to edit the host file using LabVIEW.

0 Kudos
Message 1 of 8
(4,048 Views)
Start your LabVIEW EXE as admin to have elevated access permissions...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(4,018 Views)

Thanks for the reply. Already tried as administrator. But no use.

0 Kudos
Message 3 of 8
(4,008 Views)

Have you tried changing the permissions on the file itself?

2016-04-26_09-35-32.png

 

Microsoft is generally against having applications running as users modify important system files and/or do things like edit the registry.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 8
(3,996 Views)

I can edit another file with same security permissions and in the same location. For the host file it shows error even after giving full permission.

0 Kudos
Message 5 of 8
(3,989 Views)
Like I said - Microsoft is generally against having pieces of software make modifications to important system files. It might be that the hosts file has special permissions since it can be used to override DNS settings and send users network/data to the wrong destination - you can surely imagine the number of viruses/trojan horses/phishing/scams that would take advantage of such functionality.

LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 6 of 8
(3,983 Views)

At last, I got a .bat file to add an entry in windows host file. Then run using the systemExec.vi. Now my code works exactly as it finds the server IP and adding it in the host file.

0 Kudos
Message 7 of 8
(3,938 Views)

Hello , 

i m trying the same in one project .. 

it s possible to post the solution? 
thanks 

0 Kudos
Message 8 of 8
(2,830 Views)