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!~