zoukankan      html  css  js  c++  java
  • bat脚本+diskpart 脚本实现自动划分磁盘分区

      我提供的脚本只是案例展示,真实场景需要自行修改。(正好我今天看到一个规范的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-computershareFile
    REM shareFile
    diskpart /s H:Diskdisk1config.txt
    
    :END
    echo Exiting.......

      运行结果:

    master.bat

    master.bat anychar

  • 相关阅读:
    迅为-IMX6Q开发板Android应用测试-AndroidStudio-录音机测试
    迅为3399开发板Linux固件编译
    迅为-i.MX6ULL开发板-Busybox移植DHCP(三)
    迅为-i.MX6ULL开发板-Busybox移植DHCP(二)
    itop4412开发板Qt串口编程-实现串口功能
    迅为iMX6D/Q/PLUS设备树 Android7.1.2 系统编译
    迅为3399开发板使用ADB命令传递文件到android设备
    Jlink如何校验Hex
    编码器芯片MLX90363的使用
    编程小技巧
  • 原文地址:https://www.cnblogs.com/feiquan/p/10459415.html
Copyright © 2011-2022 走看看