我提供的腳本只是案例展示,真實場景需要自行修改。(正好我今天看到一個規範的bat腳本,我放出來,大家一起學習下) 要求:將20G的磁碟1,分出4G為主分區,4G擴展分區(2個2G邏輯分區) 試驗環境: 1.主機與其他多台計算都可以建立$IPC連接,主機上共用Disk目錄,其中放有: 2.在客戶端運行 ...
我提供的腳本只是案例展示,真實場景需要自行修改。(正好我今天看到一個規範的bat腳本,我放出來,大家一起學習下)
要求:將20G的磁碟1,分出4G為主分區,4G擴展分區(2個2G邏輯分區)
試驗環境:
1.主機與其他多台計算都可以建立$IPC連接,主機上共用Disk目錄,其中放有:
2.在客戶端運行master.bat腳本,可用其他腳本或者遠程調用
腳本:
disk1config.txt
Rem Seletct Disk1 Select disk 1 list partition Rem Clean Disk1 Clean list partition Rem Create the primary partition on the disk and assign the drive letter. Create partition primary size=4096 assign letter=s format fs=ntfs label="Primary" list partition Rem Create extended partition with 2 logical divers Create partition extended size=4096 list partition Rem 1 logical Create partition logical size=2048 assign letter=u format fs=ntfs label="extended1" list partition Rem 2 logical Create partition logical size=2047 assign letter=v format fs=ntfs label="extended2" list partition
master.bat
@echo off if not "%OS%"=="Windows_NT" goto END if "%1"=="" (set INFO=echo && set SEXIT=1) else (set INFO=rem && set SEXIT=0) %INFO% ******************************* %INFO% Script:Disk1Setup.bat %INFO% Creation Date : 2019/3/1 21:52 %INFO% Last Modified : 2019/3/1 21:53 %INFO% Author: feiquan %INFO% Email: 2283320260@qq.com %INFO% ********************************* %INFO% Description: %INFO% Configures the standard partitions on workstations %INFO% with a third hard drive.The script is configured so %INFO% that is will only run if you pass in a parameter %INFO% safeguard to help prevent accidental foamtting %INFO% of disks %INFO% ********************************* %INFO% Examples: %INFO% master.bat ===^> Show infomation %INFO% master.bat anyChar ===^> Create disk partition %INFO% ********************************* if "%SEXIT%"=="1" goto END @title "Configuring Disk 1..." REM cls color 07 Rem Connect $IPC net use H: \\remote-computer\shareFile REM shareFile diskpart /s H:\Disk\disk1config.txt :END echo Exiting.......
運行結果:
master.bat
master.bat anychar