Hosts Commander - modification of hosts from the command line
I would like to devote some time to the hosts file. About two years ago, when I once again climbed into the depths of system directories in order to correct just one line in this file, I thought how cool it would be to work with hosts from the command line. Then the idea went to the diary, and for a long time remained untouched. A couple of days ago I realized almost all the ideas that came to mind about this. I share the result with the habrasociety. I would be glad if someone comes in handy.
And we got a small hosts.exe program that can be briefly described as follows:
Project page: Hosts Commander
Program: hostscmd.zip (10 kb., .NET 3.5)
Source code: repository (C #, VS2010)
If you first copy the program file to the system directory, the utility will always be ready to work in the console or by pressing Win + R.
- If no requirements are specified - Displays all hosts
- Aliases: view, select
- Example: list enabled visible local *
- Example: list vk
default is 127.0.0.1, Can Not Specify
- Paramermay be absent
- Parameters before # may have any order
- Everything after # - comment
- Aliases: new
- Example: hosts add myhost.dev
- Example: hosts add another.dev 192.168.1.1 # Remote host
- Everything after # - comment
- Aliases: update, change
- Example: hosts set myhost.dev # new comment
- Example: hosts set another.dev 192.168.1.1
- Aliases: del, remove, delete
- Example: hosts rem * .local
- Aliases: on
- Example: hosts enable localhost
- Aliases: off
- Example: hosts disable local? Ost
- Aliases: raw, file
- Parameter optional, by default it is backup
- Option optional, by default it is backup
- Useful if you have many hosts that you would not want to always see before your eyes
In the end, I would like to write that the program was written “for myself” from the very beginning, and I implemented almost all the functions that I wanted to see in it. Nevertheless, I will be glad to see some comments and suggestions in the comments.
The performance of the program was tested on Windows XP. Owners of more modern versions of Windows would like to be asked to unsubscribe how the program will behave with the included in the UAC system.
Thanks for attention.
What happened?
And we got a small hosts.exe program that can be briefly described as follows:
- Add, Remove, and Disable Hosts
- Supports operations on hosts by mask
- Simple hosts selections by attributes and mask
- Backing up hosts and rolling back the last operation
- IDN support (you can create Russian-language domains)
- IPv6 Address Support
- Alias support (multiple domain names per line)
- Preserves the original layout and encoding of the hosts file
- A large number of aliases for each team (as you prefer)
Where can I download?
Project page: Hosts Commander
Program: hostscmd.zip (10 kb., .NET 3.5)
Source code: repository (C #, VS2010)
How to use it?
If you first copy the program file to the system directory, the utility will always be ready to work in the console or by pressing Win + R.
hosts list [enabled|disabled] [visible|hidden]
- Displays hosts that meet the requirements - If no requirements are specified - Displays all hosts
- Aliases: view, select
- Example: list enabled visible local *
- Example: list vk
hosts add #
- Adds a new host, - Paramer
- Parameters before # may have any order
- Everything after # - comment
- Aliases: new
- Example: hosts add myhost.dev
- Example: hosts add another.dev 192.168.1.1 # Remote host
hosts set #
- Updates the IP address or host comment - Everything after # - comment
- Aliases: update, change
- Example: hosts set myhost.dev # new comment
- Example: hosts set another.dev 192.168.1.1
hosts rem
- Removes a specific host or matching mask - Aliases: del, remove, delete
- Example: hosts rem * .local
hosts enable
- Enables a specific host or matching mask - Aliases: on
- Example: hosts enable localhost
hosts disable
- Turns off a specific host or matching mask - Aliases: off
- Example: hosts disable local? Ost
hosts print
- Displays the original contents of the hosts file - Aliases: raw, file
hosts format
- Formats lines in a filehosts clean
- Removes comments and formats lines in a filehosts backup
- Makes a backup of the hosts file - Parameter
hosts restore
- Restores the hosts file from backup - Option
hosts rollback
- Rolls back the last operation with the hosts file hosts open
- Open the hosts file in notepadhosts hide
- Hides hosts from the list when running hosts.exe without parameters - Useful if you have many hosts that you would not want to always see before your eyes
hosts show
- Returns hosts to the main listIn the end
In the end, I would like to write that the program was written “for myself” from the very beginning, and I implemented almost all the functions that I wanted to see in it. Nevertheless, I will be glad to see some comments and suggestions in the comments.
The performance of the program was tested on Windows XP. Owners of more modern versions of Windows would like to be asked to unsubscribe how the program will behave with the included in the UAC system.
Thanks for attention.