Ghost后自动修改IP和计算机名的VBS脚本!(感觉蛮好)
现推出, 。VBS 版 Ghost 改机器名 IP地址 新版本。
AutoConfig.vbs
---------------------------------------------------------------------------
On Error Resume Next
'取得本机器的网卡物理地址: MacAddress
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
Set objNic = objWMIService.Get _
("Win32_NetworkAdapter.DeviceID=" & objNicConfig.Index)
'本机器的网卡物理地址写入变量 : strMacAddress
strMacAddress = objNic.MACAddress
Next
'读取配置文件
dim files,file,strReadLine ,RowNumber
Const ForReading = 1
set files=CreateObject("Scripting.FileSystemObject")
if files.fileexists("E:\AutoConfig\config.cfg", ForReading) then
set file=files.opentextfile("E:\AutoConfig\config.cfg")
else
msgbox("请在程序目录下放置MAC列表文件(文件名为:config.cfg)")
end if
RowNumber = 0
Do While file.AtEndOfStream <> True
strReadLine = file.ReadLine
RowNumber = RowNumber + 1
If InStr(strReadLine,strMacAddress) <> 0 Then
ComputerConfig = Split(strReadLine , ";")
Exit Do
End If
Loop
'修改IP地址
strComputer = "."
SubnetIPAddress = "192.168.0."
LocalIPAddress = SubnetIPAddress & RowNumber
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array(LocalIPAddress)
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.0.1")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
Next
'修改机器名
Set WshShell = CreateObject("Wscript.Shell")
Set Fso = CreateObject("SCripting.FileSystemObject")
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName", ComputerConfig(0) ,"REG_SZ"
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname", ComputerConfig(0) ,"REG_SZ"
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname", ComputerConfig(0) ,"REG_SZ"
'修改CS-CDKEY
WshShell.RegWrite "HKCU\Software\Valve\CounterStrike\Settings\Key", ComputerConfig(3),"REG_SZ"
WshShell.RegWrite "HKU\S-1-5-21-839522115-507921405-2146800195-500\Software\Valve\CounterStrike\Settings\Key", ComputerConfig(3),"REG_SZ"
WshShell.RegWrite "HKU\S-1-5-21-1085031214-220523388-839522115-500\Software\Valve\CounterStrike\Settings\Key", ComputerConfig(3),"REG_SZ"
WshShell.RegWrite "HKU\S-1-5-21-1614895754-1417001333-839522115-500\Software\Valve\CounterStrike\Settings\key", ComputerConfig(3),"REG_SZ"
'清除启动项
WshShell.RegDelete"HKLM\Software\Microsoft\Windows\CurrentVersion\Run\AutoConfig"
Set Wshell=Nothing
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next
On Error GoTo 0
----------------------------------------------------------------------------------------
l另存为 “ AutoConfig.vbs” 文件。
config.cfg
-----------------------------------------------------------------------------------
Nh002
Nh003
Nh004
Nh005; 00:11:5B:CF:C8:12; 192.168.0.5; 3245164654063
Nh006; 00:11:5B:BD:2F:E4; 192.168.0.6; 3385636230783
Nh007; 00:11:5B:B3:F0:86; 192.168.0.7; 2030698167302
Nh008; 00:11:5B:C8:C8:E1; 192.168.0.8; 7149496192146
Nh009; 00:11:5B:CF:C6:D9; 192.168.0.9; 6823878707810
---------------------------------------------------------------------------------
按照格式,添加 自己的机器配置。 另存为“ config.cfg”
添加启动项.reg
------------------------------------------------------------------------------
Windows Registry Editor Version 5.00
"AutoConfig"="E:\\AutoConfig\\AutoConfig.vbs"
------------------------------------------------------------------------------------------------------
另存为“ 添加启动项.reg”
先看说明.txt
--------------------------------------------------------------------------------------------
--------------------------------------------------------
###如有不明白的地方请联系我,
联系
QQ:233002600
E-mail:
digsea2000@163.com
-------------------------------------------------------
**************************************************************************************
###本程序的基本思路是:
首先在 "Config.cfg" 文件内放置全部的机器名,网卡地址, IP地址, CS-CDKEY。
程序运行后读取本机的网卡地址,再到 "Config.cfg" 文件内找相应的地址写在第几行,
来确定本机的机器名. 再根据所得到的行号,来配置应该设置的IP, CS-CDKEY,等等.
###使用步骤
1.依次填好 "Config.cfg" 文件里面的机器配置
2.在母盘做好准备克盘之前将"添加启动项.reg"导入注册表
3.克盘后重启,自动设置开始
###各文件内容介绍:
本程序主要包含4个文件:
假设你的系统是 Win2k Pro,
Autoconfig.vbs 用于2000系统的主程序.
Config.cfg 机器配置列表
添加启动项.reg 母盘制作好后运行一下,克盘会才能自动启动主程序.
先看说明.txt 帮助说明
'Autoconfig.vbs 用于2000系统的主程序.
如果,你能修改它,使程序更有效率。你就看着办,
看不懂呢,就不用管它。
'添加启动项.reg
该文件的作用就是让克好的盘在启动后能自动运行主程序,
而主程序会在运行后自动删除这个启动项目,
所以主程序只会运行一次,以后是不会自动运行的.
注意: 文件的: 盘符,路径,文件夹名字。都是设置好的。
如果,你改变路径。请把此文件中的配置也做相应修改。
'Config.cfg
文件内依次写入每台机器的MAC地址,保证1号写在第1行,8号写在第8行......
如你的机器直接从10号机编号,在上面预留9个空行,10号机的MAC就写在第10行
每一行的书写格式必须完整,
如:
Nh005; 00:11:5B:CF:C8:12; 192.168.0.5; 3245164654063
因为,IP地址,是根据 MAC 所在行的 行号确定的。
如果,某个机器号不连续,请只写机器号, 把 MAC 保持留空。
**************************************************************************************
-----------------------------------------------------------------------------------------------
另存为“先看说明.txt”文件。
把以上 四个文件 放在“ E:\Autoconfig\ " 文件夹 下面。
放在别出,你要修改,“AutoConfig.vbs”,“ 添加启动项.reg”
这两个文件。按照以上路径呢,你就可以,只修改你的机器配置了!~
VBS script that automatically modifies IP and computer name after Ghost! (Seems quite good)
Now launched, the. VBS version of the Ghost machine name and IP address new version.
AutoConfig.vbs
---------------------------------------------------------------------------
On Error Resume Next
'Get the physical address of the local machine's network card: MacAddress
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
Set objNic = objWMIService.Get _
("Win32_NetworkAdapter.DeviceID=" & objNicConfig.Index)
'Write the physical address of the local machine's network card to variable: strMacAddress
strMacAddress = objNic.MACAddress
Next
'Read the configuration file
dim files,file,strReadLine ,RowNumber
Const ForReading = 1
set files=CreateObject("Scripting.FileSystemObject")
if files.fileexists("E:\AutoConfig\config.cfg", ForReading) then
set file=files.opentextfile("E:\AutoConfig\config.cfg")
else
msgbox("Please place the MAC list file (file name: config.cfg) in the program directory")
end if
RowNumber = 0
Do While file.AtEndOfStream <> True
strReadLine = file.ReadLine
RowNumber = RowNumber + 1
If InStr(strReadLine,strMacAddress) <> 0 Then
ComputerConfig = Split(strReadLine , ";")
Exit Do
End If
Loop
'Modify IP address
strComputer = "."
SubnetIPAddress = "192.168.0."
LocalIPAddress = SubnetIPAddress & RowNumber
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array(LocalIPAddress)
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.0.1")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
Next
'Modify machine name
Set WshShell = CreateObject("Wscript.Shell")
Set Fso = CreateObject("SCripting.FileSystemObject")
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName", ComputerConfig(0) ,"REG_SZ"
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname", ComputerConfig(0) ,"REG_SZ"
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname", ComputerConfig(0) ,"REG_SZ"
'Modify CS-CDKEY
WshShell.RegWrite "HKCU\Software\Valve\CounterStrike\Settings\Key", ComputerConfig(3),"REG_SZ"
WshShell.RegWrite "HKU\S-1-5-21-839522115-507921405-2146800195-500\Software\Valve\CounterStrike\Settings\Key", ComputerConfig(3),"REG_SZ"
WshShell.RegWrite "HKU\S-1-5-21-1085031214-220523388-839522115-500\Software\Valve\CounterStrike\Settings\Key", ComputerConfig(3),"REG_SZ"
WshShell.RegWrite "HKU\S-1-5-21-1614895754-1417001333-839522115-500\Software\Valve\CounterStrike\Settings\key", ComputerConfig(3),"REG_SZ"
'Delete startup item
WshShell.RegDelete"HKLM\Software\Microsoft\Windows\CurrentVersion\Run\AutoConfig"
Set Wshell=Nothing
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next
On Error GoTo 0
----------------------------------------------------------------------------------------
Save as " AutoConfig.vbs" file.
config.cfg
-----------------------------------------------------------------------------------
Nh002
Nh003
Nh004
Nh005; 00:11:5B:CF:C8:12; 192.168.0.5; 3245164654063
Nh006; 00:11:5B:BD:2F:E4; 192.168.0.6; 3385636230783
Nh007; 00:11:5B:B3:F0:86; 192.168.0.7; 2030698167302
Nh008; 00:11:5B:C8:C8:E1; 192.168.0.8; 7149496192146
Nh009; 00:11:5B:CF:C6:D9; 192.168.0.9; 6823878707810
---------------------------------------------------------------------------------
Add your own machine configuration according to the format. Save as "config.cfg"
Add Startup Item.reg
------------------------------------------------------------------------------
Windows Registry Editor Version 5.00
"AutoConfig"="E:\\AutoConfig\\AutoConfig.vbs"
------------------------------------------------------------------------------------------------------
Save as " Add Startup Item.reg"
Read the instructions.txt
--------------------------------------------------------------------------------------------
--------------------------------------------------------
###If you have any questions, please contact me,
Contact
QQ: 233002600
E-mail:
digsea2000@163.com
-------------------------------------------------------
**************************************************************************************
###The basic idea of this program is:
First, place all machine names, network card addresses, IP addresses, and CS-CDKEY in the "Config.cfg" file.
After the program runs, it reads the local network card address, then finds the corresponding address in the "Config.cfg" file to determine which line it is on,
to determine the local machine name. Then, according to the obtained line number, it configures the IP, CS-CDKEY, etc. that should be set.
###Usage steps
1. Fill in the machine configuration in the "Config.cfg" file in sequence
2. Before making the master disk and preparing to clone, import "Add Startup Item.reg" into the registry
3. After cloning, restart, and the automatic setup starts
###Introduction to the contents of each file:
This program mainly contains 4 files:
Assuming your system is Win2k Pro,
Autoconfig.vbs is the main program for the 2000 system.
Config.cfg is the machine configuration list
Add Startup Item.reg is run after the master disk is made, and the main program can be automatically started after cloning.
Read the instructions.txt is the help instructions
'Autoconfig.vbs is the main program for the 2000 system.
If you can modify it to make the program more efficient. You can do as you like,
If you don't understand, just ignore it.
'Add Startup Item.reg
The function of this file is to make the cloned disk automatically run the main program after startup,
and the main program will automatically delete this startup item after running,
so the main program will only run once and will not run automatically in the future.
Note: The drive letter, path, and folder name in the file are all set.
If you change the path. Please make corresponding modifications to the configuration in this file.
'Config.cfg
Write the MAC address of each machine in the file in sequence, ensure that the No. 1 is written in the first line, and No. 8 is written in the 8th line......
If your machine is numbered directly from No. 10, leave 9 empty lines above, and the MAC of No. 10 machine is written in the 10th line
The writing format of each line must be complete,
such as:
Nh005; 00:11:5B:CF:C8:12; 192.168.0.5; 3245164654063
Because the IP address is determined by the line number where the MAC is located.
If a certain machine number is not continuous, please only write the machine number and keep the MAC empty.
**************************************************************************************
-----------------------------------------------------------------------------------------------
Save as "Read the instructions.txt" file.
Put the above four files in the "E:\Autoconfig\ " folder.
If placed elsewhere, you need to modify "AutoConfig.vbs" and " Add Startup Item.reg".
With the above path, you can only modify your machine configuration!~