标签:erro remove skin exit device cto rem move 一个
如果电脑只配置有一块或多块普通磁盘,则选择disk0安装OS;
如果电脑同时配置有SSD+其他磁盘,则选择SSD安装OS;
如果系统磁盘容量<200G,则只分区一个C盘,>200G则分区为C和D盘。
实现方式:
1.编辑UserExit.vbs脚本,增加如下3个函数,实际上DiskNum()函数在此用不到
Function UserExit(sType, sWhen, sDetail, bSkip) oLogging.CreateEntry "entered UserExit ", LogTypeInfo UserExit = Success End Function ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘ ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘ ‘如果有固态硬盘存在,则OS安装在固态硬盘,否则安装到磁盘0上 Function SelectOSDisk() ‘查找固态硬盘 Set Wmi = GetObject("Winmgmts:\\.\Root\Microsoft\Windows\Storage") Set objDisk = Wmi.Execquery("Select * from MSFT_PhysicalDisk") For Each B in objDisk if B.MediaType=4 then DiskID=B.DeviceId end if next ‘固态硬盘不存在,则指定disk0 if DiskID = "" then DiskID=0 end if SelectOSDisk = DiskID End Function ‘查找物理磁盘数量 Function DiskNum() Set Wmi = GetObject("Winmgmts:\\.\Root\Microsoft\Windows\Storage") Set objDisk = Wmi.Execquery("Select * from MSFT_PhysicalDisk") n = 0 For Each B in objDisk n = n+1 next DiskNum = n End Function ‘获取OS Disk Size Function GetOSDiskSize(OSDiskID) Set Wmi = GetObject("Winmgmts:\\.\Root\Microsoft\Windows\Storage") Set objOSDisk = Wmi.Execquery("Select * from MSFT_PhysicalDisk Where DeviceId = ‘" & OSDiskID & "‘") For Each osdisk in objOSDisk GetOSDiskSize=osdisk.size Next End Function ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘
2.在CustomSettings.ini文件添加如下内容:
Properties=MyCustomProperty,OSDDiskSize,DiskNum #增加自定义属性OSDDiskSize,DiskNum;OSDDiskIndex为系统默认变量参数,无需再次添加
#引用如下内容,获取变量值
UserExit=UserExit.vbs ;获取磁盘ID,磁盘大小 OSDDiskIndex=#SelectOSDisk()# OSDDiskSize=#GetOSDiskSize(%OSDDiskIndex%)# ;DiskNum=#DiskNum()#
3.编辑TS,复制添加Format and Partition Disk(BIOS/UEFI),一个判断磁盘是否小于200G,一个判断磁盘是否大于200G
4.添加一个自定义PS1脚本,用于格式第二块磁盘
脚本内容如下:
InitDataDisk.bat
powershell.exe -executionpolicy bypass -noprofile -noninteractive -file "%~dp0\InitDataDisk.ps1"
InitDataDisk.ps1
#对非OS所在磁盘(只操作第一块非OS磁盘)初始化并分区,磁盘容量小于500G只分一个分区,高于500G分两个分区 $disks = Get-Disk | ? {$_.IsSystem -eq $False} $driver_letters = ls function:[A-Z]: | where { ! (test-path $_.name) }| select -ExpandProperty name if ($disks -ne $null) { #Clear Disk data. try { $ErrorActionPreference=‘stop‘ $disks[0] | Clear-Disk -RemoveData -Confirm:$false Start-Sleep 1 } catch {} #Init Disk. Initialize-Disk $disks[0].Number if ($disks[0].Size -le 500GB) { $disks[0] |New-Partition -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel Data -Confirm:$false $dletter = $driver_letters[2].split(":")[0] $disks[0] |Get-Partition | where {$_.PartitionNumber -eq 2} | Set-Partition -NewDriveLetter $dletter } else { $par1_size = 500GB $par3_size = $disks[0].Size - $par1_size $disks[0] |New-Partition -Size $par1_size | Format-Volume -FileSystem NTFS -NewFileSystemLabel Data -Confirm:$false Start-Sleep 1 $disks[0] |New-Partition -Size $par2_size | Format-Volume -FileSystem NTFS -NewFileSystemLabel Data -Confirm:$false $dletter2 = $driver_letters[2].split(":")[0] $dletter3 = $driver_letters[3].split(":")[0] $disks[0] |Get-Partition | where {$_.PartitionNumber -eq 2} | Set-Partition -NewDriveLetter $dletter2 $disks[0] |Get-Partition | where {$_.PartitionNumber -eq 3} | Set-Partition -NewDriveLetter $dletter3 } }
标签:erro remove skin exit device cto rem move 一个
原文地址:https://www.cnblogs.com/dreamer-fish/p/13175537.html