![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-10 18:26 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Ask: How to read and modify the local computer name and workgroup in batch processing? |
| Printable Version 4,469 / 8 |
| Floor1 yaoguof | Posted 2006-10-23 01:52 |
| 初级用户 Posts 35 Credits 90 | |
|
Searched a lot of materials and couldn't find it. Could anyone please give some guidance?
How to read and modify the computer name and workgroup of the local machine? Thanks |
|
| Floor2 electronixtar | Posted 2006-10-23 02:43 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
It is related to the registry, not much related to batch processing. Just search for the registry key value of the computer name, and use the reg command.
|
|
| Floor3 vkill | Posted 2006-10-23 03:44 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
Query the computer name of the local machine: hostname
To modify, I guess I need to modify the registry~ |
|
| Floor4 3742668 | Posted 2006-10-23 04:56 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
```
@echo off echo The local computer name is: %COMPUTERNAME% echo Workgroup/domain: wmic computersystem get domain pause echo More detailed information: systeminfo rem wmic computersystem Change: After changing the computer name, the name seen in the right - click of "My Computer" has not changed, but the computer name can be seen to have changed from set, systeminfo, and wmic. ``` |
|
| Floor5 vkill | Posted 2006-10-23 04:57 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
| Floor6 yaoguof | Posted 2006-10-23 05:46 |
| 初级用户 Posts 35 Credits 90 | |
|
Thanks to the moderator's reply. How can I make the workgroup in the properties of "My Computer" change together? There is no workgroup in the registry. It seems that modifying the workgroup through the registry doesn't work.
|
|
| Floor7 3742668 | Posted 2006-10-23 06:08 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Sweat one, you replied without even trying?
I said it can't be displayed only when the permission is insufficient. If it's a member of the administrators group without restrictions, you can directly see the change. If there are still problems, refer to <Help and Support> and /?. |
|
| Floor8 bosskof | Posted 2006-10-24 13:05 |
| 初级用户 Posts 11 Credits 22 | |
|
Why is my run not successful?
It shows: No available example. Mine is the 2003 system Also: After entering computersystem /?, the following appears Usage: COMPUTERSYSTEM ASSOC [<format specifier>] COMPUTERSYSTEM CALL <method name> [<actual param list>] COMPUTERSYSTEM CREATE <assign list> COMPUTERSYSTEM DELETE COMPUTERSYSTEM GET [<property list>] [<get switches>] COMPUTERSYSTEM LIST [<list format>] [<list switches>] COMPUTERSYSTEM SET [<assign list>] Hope to give a rough explanation, thank you moderator |
|
| Floor9 lzys | Posted 2006-10-24 17:55 |
| 初级用户 Posts 28 Credits 54 | |
|
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!~ |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |