bat脚本+diskpart 脚本实现自动划分磁盘分区
程序员文章站
2023-08-28 23:40:04
我提供的脚本只是案例展示,真实场景需要自行修改。(正好我今天看到一个规范的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
上一篇: 他已经做好了新学期的准备了
下一篇: 芋艿是什么?没想到我们生活中很常见!