|
|
已知hosts文件,格式如下:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
10.123.1.21 W0222201
10.123.1.22 W0222202
10.123.1.31 ES02222101
10.123.1.32 ES02222102
10.123.1.33 ES02222103
10.123.1.34 ES02222104
10.123.1.35 ES02222105
10.123.1.36 ES02222106
10.123.1.37 ES02222107
问题:能否写一个vbs或者bat,可以实现以下步骤:
1;读取10.123.1.21,并将注册表下某项值设为W0222201;读取10.123.1.22,并将注册表下某项值设为W0222202;
2;将本机的ip与hosts文件中的ip比较(从10.123.1.31开始比较),如在hosts文件中存在,则将注册表下主机名项改成右边项的值(10.123.1.31的主机名改成ES02222101)
3;将本机的ip与hosts文件中的ip比较(从10.123.1.31开始比较),如在hosts文件中存在,则将注册表下另一项改成右边列的后三位(10.123.1.31的另一项改成101) |
|