ZTI基于SQL判断计算机重新分区解决方案
| '//--------------------------------------------------------------------------- '// '// '// File: ZTIUserExit.vbs '// '// Function: UserExit() '// '// Input: sType - user exit type (PHASE, SECTION) '// sWhen - when being called (BEFORE, AFTER) '// sDetail - detail for the exist (phase name, section name) '// bSkip - flag to indicate whether to skip normal processing (only possible with BEFORE) '// '// Return: Success - 0 '// Failure - 1 '// '// Purpose: This is a sample user exit, showing some of the capabilities of a user exit. '// '//--------------------------------------------------------------------------- Function UserExit(sType, sWhen, sDetail, bSkip) Dim iRetVal LogInfo sLogFile, "User exit started: " & sType & " " & sWhen & " " & sDetail, LogTypeInfo iRepartition = dicUserData("Repartition") If sType = "PHASE" and sDetail = "PREINSTALL" and sWhen = "BEFORE" then ' Check to see if Windows PE is running from a different drive than the first disk partition ' (as identified by OSD). If this is the case, then this is a new machine and we can ' repartition and format the drive. If iRepartition = "Y" then If Left(objOSD("OSDTARGETDRIVE"), 2) <> Left(wshEnv("SystemDrive"), 2) then ' First run DISKPART LogInfo sLogFile, "USEREXIT: About to run Diskpart.", LogTypeInfo iRetVal = wshShell.Run("DISKPART.EXE /s """ & sThisScriptDir & "\ZTIDiskPart.txt""", 0, true) If iRetVal <> Success then LogInfo sLogFile, "USEREXIT: ERROR - Diskpart returned a non-zero return code, rc = " & iRetVal, LogTypeError UserExit = iRetVal EXIT FUNCTION End if ' Wait a few seconds WScript.Sleep 5000 ' Now run a quick format LogInfo sLogFile, "USEREXIT: About to run quick format.", LogTypeInfo iRetVal = wshShell.Run("FORMAT C: /FS:NTFS /V:OSDisk /Q /Y", 0, true) iRetVal = wshShell.Run("FORMAT d: /FS:NTFS /V:OSDisk /Q /Y", 0, true) iRetVal = wshShell.Run("FORMAT e: /FS:NTFS /V:OSDisk /Q /Y", 0, true) If iRetVal <> Success then LogInfo sLogFile, "USEREXIT: ERROR - Quick format returned a non-zero return code, rc = " & iRetVal, LogTypeError UserExit = iRetVal EXIT FUNCTION End if Else LogInfo sLogFile, "USEREXIT: Windows PE is running from the system drive, must be a refresh.", LogTypeInfo End if Else LogInfo sLogFile, "USEREXIT: No user exit processing is required.", LogTypeInfo End if end if UserExit = Success End Function |
| [Settings] Priority= DefaultGateway, SQL, RoleQuery, ComputerQuery, MACADDRESS, Default CustomKeysUserData=UDShare,UDDir,UDProfiles,SLShare,OSInstall,Packages(*),Administrators(*),DriverPaths(*),PowerUsers(*),Role,Repartition CustomKeysSysprep=ComputerName,TimeZone,JoinDomain,MachineObjectOU OSDVariableKeys=OSDINSTALLSILENT,OSDINSTALLPACKAGE,OSDINSTALLPROGRAM,OSDNEWMACHINENAME ScanStateArgs=/i:updateuser.inf /i:userdata.inf /v:7 /c LoadStateArgs=/v:7 /c UserExit=ZTIUserExit.vbs [Default] ComputerName=%OSDNEWMACHINENAME% UDDir=%OSDCOMPUTERNAME% CaptureGroups=No [DefaultGateway] 192.168.11.1=NYC [NYC] SQLDefault=DB_BDD [DB_BDD] SQLServer=smsroot Database=BDDAdminDB Table=BDDAdminCore Parameters=MacAddress [RoleQuery] SQLDefault=DB_RoleQuery [ComputerQuery] SQLDefault= DB_ComputerQuery [DB_RoleQuery] SQLServer=smsroot Database=BDDAdminDB Table=RolePackages Parameters=Role SQLShare=Logs [DB_ComputerQuery] SQLServer=smsroot Database=BDDAdminDB Table=ComputerPackages Parameters=MacAddress SQLShare=Logs [SMS] SQLServer=smsroot Database=SMS_one Table=v_Program Parameters=PackageID,ProgramName [SysprepInfMapping] ComputerName=UserData TimeZone=GuiUnattended JoinDomain=Identification MachineObjectOU=Identification |