Exemplo n.º 1
0
        private void TwiceAttachVHDAndWriteBootFile()
        {
            if (!NeedTwiceAttach)
            {
                return;
            }
            //if (!ShouldContinue) return;
            //AttachVHD(StringOperation.Combine(WTGOperation.WTGModel.ud, win8VhdFile));

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("select vdisk file=" + StringUtility.Combine(WTGModel.ud, WTGModel.win8VHDFileName));
            sb.AppendLine("attach vdisk");
            sb.AppendLine("sel partition 1");
            sb.AppendLine("assign letter=v");
            sb.AppendLine("exit");
            DiskpartScriptManager dsm = new DiskpartScriptManager();

            dsm.Args = sb.ToString();
            dsm.RunDiskpartScript();


            if (!Directory.Exists("V:\\"))
            {
                Log.WriteLog("TwiceAttachVhdError.log", "二次加载VHD失败");
                throw new VHDException(MsgManager.GetResString("Msg_VHDCreationError", MsgManager.ci));
            }
            //需要二次加载,一定不是需要写入X盘的UEFI模式
            if (WTGModel.ntfsUefiSupport)
            {
                BootFileOperation.BcdbootWriteBootFile(@"V:\", WTGModel.ud, FirmwareType.ALL);
            }
            else
            {
                BootFileOperation.BcdbootWriteBootFile(@"V:\", WTGModel.ud, FirmwareType.BIOS);
            }
            DetachVHD(StringUtility.Combine(WTGModel.ud, WTGModel.win8VHDFileName));
            if (!File.Exists(WTGModel.ud + "\\Boot\\BCD"))
            {
                CopyVHDBootFiles();
                //Log.WriteLog ("TwiceAttachFailed.log")
            }
        }
Exemplo n.º 2
0
        private void WriteBootFilesIntoVHD()
        {
            if (WTGModel.isUefiGpt && !WTGModel.isLegacyUdiskUefi)
            {
                BootFileOperation.BcdbootWriteBootFile(@"V:\", @"X:\", FirmwareType.UEFI);
                //ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, "  " + "V:\\" + "windows  /s  x: /f UEFI");
            }
            else if (WTGModel.isUefiMbr)
            {
                BootFileOperation.BcdbootWriteBootFile(@"V:\", @"X:\", FirmwareType.ALL);
                BootFileOperation.BooticeWriteMBRPBRAndAct("X:");
                //ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, "  " + "V:\\" + "windows  /s  x: /f ALL");
            }
            else if (WTGModel.isWimBoot)
            {
                BootFileOperation.BcdbootWriteBootFile(@"V:\", WTGModel.ud, FirmwareType.BIOS);
                //ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, "  " + "V:\\" + "windows  /s  " + WTGOperation.WTGModel.ud.Substring(0, 2) + " /f ALL");
            }
            else
            {
                //if (!WTGModel.userSettings.CommonBootFiles)
                //{
                if (WTGModel.ntfsUefiSupport)
                {
                    BootFileOperation.BcdbootWriteBootFile(@"V:\", WTGModel.ud, FirmwareType.ALL);
                }
                else
                {
                    BootFileOperation.BcdbootWriteBootFile(@"V:\", WTGModel.ud, FirmwareType.BIOS);
                }
                //ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, "  " + "V:\\" + "windows  /s  " + WTGOperation.WTGModel.ud.Substring(0, 2) + " /f ALL");
                //}
                //else
                //{
                //    CopyVHDBootFiles();

                //}
            }
        }