Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Add domain script automatically. Bat and vbs are used together to make the operation of adding domain easier.

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

My experiment: writing an auto-add domain script (summary)

1. The purpose of automatically adding domain scripts.

A. reduce repetitive and complicated necessary operations and improve work efficiency.

B, make the operation of adding domain easier and more fun.

2. The realization of automatic domain addition is divided into three steps.

A. use bat and vbs to cooperate with each other. (because my programming level is not high)

B. change the name of the computer. (no need to restart the computer)

C. Change the computer IP address and DSN. (select automatic acquisition to also enable manual configuration)

D, call the Vbs file to complete the automatic domain addition operation. (does not explain why vbs is called instead of being done directly with bat)

3. Related documents.

A, link: https://pan.baidu.com/s/1sZmCisS1QEDu3E12_Ko4FA

Extraction code: bmfr

4. Script interpretation and matters needing attention.

A, modify the computer name + modify the IP address. Bat

Note:

1, the following bold part can be modified, such as: computer name format; manual DNS I wrote dead, I change according to the actual environment.

2. The way to call vbs is the "automatically add domain script .vbs" file in the root directory of disk c. You can also put it on the shared server and write the path, so that a bat file is fine on the client side. You will also change according to the actual circumstances.

@ ECHO off

Color 4E

Mode con: cols=75 lines=35

Title ⅸ Auto Join Domain @ neal ⅷ

ECHO

ECHO automatic add domain batch processing

ECHO

ECHO

ECHO starts related system services.

Sc config LmHosts start= AUTO

Net start "TCP/IP NetBIOS Helper"

Sc config Browser start= AUTO

Net start "Computer Browser"

Sc config Winmgmt start= AUTO

Net start "Windows Management Instrumentation"

Sc config LanmanServer start= AUTO

Net start "Server"

Sc config LanmanWorkstation start= AUTO

Net start "Workstation"

ECHO.

The ECHO service startup is complete.

Pause > nul

Cls

ECHO.

ECHO

ECHO modifies machine name

ECHO

ECHO

ECHO.

The ECHO machine name is similar to this format (ipt-000000-zida)

ECHO.

ECHO

ECHO.

Set / p name= Please enter the machine name:

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet001\ Control\ ComputerName\ ActiveComputerName" / v ComputerName / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet001\ Control\ ComputerName\ ComputerName" / v ComputerName / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet001\ Services\ Tcpip\ Parameters" / v "NV Hostname" / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet001\ Services\ Tcpip\ Parameters" / v Hostname / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet002\ Control\ ComputerName\ ActiveComputerName" / v ComputerName / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet002\ Control\ ComputerName\ ComputerName" / v ComputerName / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet002\ Services\ Tcpip\ Parameters" / v "NV Hostname" / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ ControlSet002\ Services\ Tcpip\ Parameters" / v Hostname / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Control\ ComputerName\ ActiveComputerName" / v ComputerName / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Control\ ComputerName\ ComputerName" / v ComputerName / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Services\ Tcpip\ Parameters" / v "NV Hostname" / t reg_sz / d% name% / f > nul 2 > nul

Reg add "HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Services\ Tcpip\ Parameters" / v Hostname / t reg_sz / d% name% / f > nul 2 > nul

ECHO.

The ECHO machine name has been modified.

Echo.

Echo = = modify [local connection] ip address = =

Echo.

Echo 1: automatic acquisition

Echo.

Echo 2: reopen ip addr

Echo.

Echo.

Set/p sel=, please select the modification method:

If "% sel%" = = "1" goto auto

If "% sel%" = = "2" goto zt

Echo you did not choose to modify it.

Goto end

: auto

Netsh interface ip set address name= "Local connection" source=dhcp

Netsh interface ip delete dns "Local connection" all

Ipconfig / flushdns

Ipconfig / all

Goto end

: zt

Echo is changing the IP address. Please wait a moment.

Netsh interface ip set address name= "Local connection" source=dhcp

Netsh interface ip set dns name= "Local connection" source=static addr=10.211.55.55

Netsh interface ip add dns name= "Local connection" addr=8.8.8.8 index=2

Ipconfig / flushdns

Ipconfig / all

Echo change IP address completed!

Goto end

: end

Pause

@ echo off

C:\ automatically add domain script .vbs

Echo aaa

B, automatically add domain script .vbs

Note:

1. The domain name in my experiment is: yft.com domain administrator: administrator password is: abcd#1324 you change according to the actual environment.

On Error Resume Next

Dim domain

Set domain = createobject ("wscript.shell")

Const JOIN_DOMAIN = 1

Const ACCT_CREATE = 2

Const ACCT_DELETE = 4

Const WIN9X_UPGRADE = 16

Const DOMAIN_JOIN_IF_JOINED = 32

Const JOIN_UNSECURE = 64

Const MACHINE_PASSWORD_PASSED = 128,

Const DEFERRED_SPN_SET = 256

Const INSTALLINVOCATION = 262144

'Domain Name

StrDomain = "yft.com"

'administrator member password

StrPassword = "abcd#1234"

'administrator member

StrUser = "administrator"

Set objNetwork = CreateObject ("WScript.Network")

StrComputer = objNetwork.ComputerName

Set objComputer = GetObject ("winmgmts: {impersonationLevel=Impersonate}!\" &

StrComputer & "\ root\ cimv2:Win32ComputerSystem.Name='" &

StrComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup (strDomain

StrPassword, strDomain & "\" & strUser, NULL

JOIN_DOMAIN + ACCT_CREATE)

Wscript.echo "Join Domain Success!"

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.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report