Appending a wildcard IP entry to /etc/hosts on Windows

Continuing the discussion from Appending entry into the HOSTS file:

I would like to pop-up a field where the user can choose their own IP to be appended to /etc/hosts

action parameter query “IP” with description “Please specify the IP of the application you wish to use”

waithidden cmd.exe /C echo {“{parameter “IP” of action} Our-Server-01.any.domain.dcd”} >> {(pathname of system folder as string & “\drivers\etc\hosts”)}

I don’t think I can nest {} like this. Is there a better way to do it?

Hi Shaun, try this out and see if it works:

waithidden cmd.exe /C echo {parameter "IP" & " Our-Server-01.any.domain.dcd"} >> "{pathname of system folder as string}\drivers\etc\hosts"

In actionscript I often find myself replacing or omitting curly braces for parameters and files as needed. Usually I use () instead but sometimes you can just leave them out since they’re already in a relevance block.

1 Like

Thanks Sean, based on that I set it up this way and it worked well:

waithidden cmd.exe /C echo {parameter “IP” & " Our-Server-01.any.domain.dcd"} >> {(pathname of system folder as string & “\drivers\etc\hosts”)}

1 Like

Related: