In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Recently, the unit has to change a batch of computers, do not have the money to buy high-end software, and are not allowed to use tripartite tools.
First write a gadget that automatically sets the computer name and add domain.
Features:
Complete the last step of system setup, change the computer name, and join the domain.
Mode of work:
Semi-automatic, you need to enter the computer name manually.
To be improved: the current computer name can be obtained automatically through the mapping table of MAC and computer name, which is fully automatic!
Readme:
Note:
Modify setdoman.bat, set domain name and domain administrator account and password
1. Run initial-config for configuration for the first time. If you do not enter the current user name and password of the system, the system will not log in automatically.
2. If it is the master disk, choose to shut down the computer and restart to enter the USB disk backup system.
3. If a single computer chooses to restart
4. prompt for the computer name for the first time, enter the computer name
5. Start to join the domain for the second time, and automatically shut down the machine after running the script.
6. Finish
-
Ver1
Added to prevent accidental deletion of setdomain scripts from running separately
Added no modification of the default domain information will prompt for manual input.
File structure:
└─ joindomain-ver1
How to use └─ readme.txt #
└─ initial-config.bat # initialization Settings File
The file called by └─ start.bat # is called again through start to rename and add domain
└─ modifyhostname.bat # modify the computer name file
└─ setdomain.bat # joins domain files and is also responsible for cleaning up the resulting temporary files
Each script needs to be run as an administrator, so you need to add the following code at the beginning
@ echo off > nul 2 > & 1 "% SYSTEMROOT%\ system32\ cacls.exe"% SYSTEMROOT%\ system32\ config\ system" if'% errorlevel%' NEQ'0' (goto UACPrompt) else (goto gotAdmin): UACPromptecho Set UAC = CreateObject^ ("Shell.Application" ^) > "% temp%\ getadmin.vbs" echo UAC.ShellExecute "% ~ s0", "runas" 1 > > "% temp%\ getadmin.vbs"% temp%\ getadmin.vbs" exit / B:gotAdminif exist "% temp%\ getadmin.vbs" (del "% temp%\ getadmin.vbs")
Script code on:
Initial-config.bat
::-inilazition-:: current account and password, restart automatic access system set / p account-name= current account name: set / p account-pw= password: modify the registry Boot automatically into the system reg add "HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon" / v AutoAdminLogon / t REG_SZ / D1 / freg add "HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon" / v DefaultPassword / t REG_SZ / d% account-pw% / freg add "HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon" / v DefaultUserName / t REG_SZ / d% account-name% / FRV: Copy and change the computer name and add the domain program to the temporary path set source=%~dp0%set dest= "C:\ Users\% username%\ AppData\ Roaming\ Microsoft\ Windows\ Start Menu\ Programs\ Startup\" copy% source%modifyhostname.bat% temp%\ modifyhostname.batcopy% source%setdomain.bat% temp%\ setdomain.batcopy% source%start.bat% dest% "start.bat" echo program initialization completed echo production master disk, please enter [y] The system shuts down automatically. Echo single computer input [n], the system automatically restarts. Set / p input-type=y/n:if% input-type%==y (the echo system is shutting down, do not operate. Shutdown / s / f / t 2goto end) the echo system is rebooting, please misoperate. Shutdown / r / f / t 2
Start.bat
Echo IT Automation tool running if not exist "% temp%\ set-temp-flag.flag" (:: run modify computer name script% temp%\ modifyhostname.bat) else (:: after restart, run join domain script% temp%\ setdomain.bat) pause
Modifyhostname.bat
Rem modify computer name set cmscdomain=cmsc.localset / p computer-name=Input computername: wmic computersystem where "caption='%computername%'" call Rename name='%computer-name%'echo 1 > > "% temp%\ set-temp-flag.flag" echo% computer-name% modification completed! restart the system in 2 seconds. Shutdown / f / r / t 2pause
Setdomain.bat
Rem this tool flashes by, indicating that there is an error:: determine whether the tag file exists, if it does not exist, it ends. Set cmscdomain=defaultset domainuser=defaultset userpw=defaultif exist "% temp%\ set-temp-flag.flag" (the last three lines of the echo real name are not modified, prompting for domain information. If% cmscdomain%==default (set / p cmscdomain= "Domain Name:") if% domainuser%==default (set / p domainuser= "User Name:") if% userpw%==default (set / p userpw= "Password:") wmic computersystem where "caption='%computername%'" call JoinDomainOrWorkgroup name=% cmscdomain% "username="% domainuser% "password="% userpw% "Fjoinoptions=1reg delete" HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon "/ v AutoAdminLogon / freg delete" HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon "/ v DefaultPassword / freg delete" HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon "/ v DefaultUserName / fdel" C:\ Users\% username%\ AppData\ Roaming\ Microsoft\ Windows\ Start Menu\ Programs\ start.bat "del"% temp%\ set-temp-flag.flag "del"% ~ dp0%\ modifyhostname.bat "echo done Please wait shutdownshutdown / s / f / t 10del "% ~ dp0%\ setdomain.bat") echo did not find the tag file Please follow the steps to run pause
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Implementing secure SCADASecuring SCADA is really a tough job when it has to be implementedpractical
© 2024 shulou.com SLNews company. All rights reserved.