标签 WinPE 下的文章

BCDEdit命令行增加WinPE启动项

在Windows 2000/XP/2003时代,系统采用NTLDR Boot Loader读取boot.ini文本文件的方法来读取系统启动项信息。Vista极其以后的系统采用Bootmgr读取BCD store的方式来读取启动项。BCD信息无法直接通过文本编辑器修改,因为它是一个二进制文件。我们可以通过微软自带的BCDEdit工具来修改、创建、删除启动项极其相关设置。

其实BCD文件就是一个注册表配置单元(registry hive)。可以用注册表管理器加载修改然后卸载。BCD里面的存储项用对象(objects)来分类。每一个对象的名称都是一个38位(包含'{'、'}'和四个'-')的GUID,类似于{02d8887d-7376-11e3-8968-c7419257e3c2}这样。 符号之间是32位16进制的数字。

BCD文件就是一个注册表配置单元(registry hive)

BCDEdit增加WinPE启动项命令行如下:

bcdedit.exe /create {GUID_RO} /device
bcdedit.exe /set {GUID_RO} ramdisksdidevice partition=c:
bcdedit.exe /set {GUID_RO} ramdisksdipath \tunps.com\boot.sdi

bcdedit.exe /create {GUID} /d "WinPE for tunps.com" /application OSLOADER
bcdedit.exe /set {GUID} device ramdisk=[c:]\tunps.com\winpe.wim,{GUID_RO}
bcdedit.exe /set {GUID} osdevice ramdisk=[c:]\tunps.com\winpe.wim,{GUID_RO}
bcdedit.exe /set {GUID} systemroot \windows
bcdedit.exe /set {GUID} detecthal yes
bcdedit.exe /set {GUID} winpe yes
bcdedit.exe /ems {GUID} OFF
bcdedit.exe /displayorder {GUID} /addlast
bcdedit.exe /default {GUID}
bcdedit.exe /timeout 10

首先需要创建一个ramdiskoptions的一个device,您可以直接/create {ramdiskoptions},但是{ramdiskoptions}一个bcd store里面只有一个,如果本机需要多个WinPE启动项就不适用了,所以建议使用/devcice。另外不知道是不是Windows的一个Bug,设置了ramdiskoptions的description之后,启动项将会变为ramdiskoptions的description,而不是启动项的description。所以建议不要设置ramdiskoptions的description

请将上面的{GUID_RO}和{GUID}设置为您需要的GUID识别符。如果没有,可以使用Windows SDK或者是Visual Studio自带的guidgen.exe工具生成的随机GUID。

删除的方法如下:

bcdedit.exe /delete {GUID_RO} /f 
bcdedit.exe /delete {GUID} /f

关于具体bcdedit的参数解释参见BCDedit_reff.docx

DISM 您没有装载或修改此映像的权限。

执行:

C:>dism /mount-wim /wimfile:e:\winpe40.wim /index:1 /mountdir:e:\40

报错:

部署映像服务和管理工具 版本: 6.1.7600.16385

错误: 0xc1510111

您没有装载或修改此映像的权限。 请验证您是否有读/写权限,或者使用 /ReadOnly 选项装载此映像。注意,无法使用只读权限提交>对映像所做的更改。

可以在 C:\Windows\Logs\DISM\dism.log 上找到 DISM 日志文件

DISM错误日志:

WIM open failed with access denied. - CWimImageInfo::Mount(hr:0xc1510111)
d:\w7rtm\base\ntsetup\opktools\dism\providers\wimprovider\dll\wimmanager.cpp:999 - CWimManager::InternalOpMount(hr:0xc1510111)
d:\w7rtm\base\ntsetup\opktools\dism\providers\wimprovider\dll\wimmanager.cpp:2247 - CWimManager::InternalCmdMount(hr:0xc1510111)
Error executing command - CWimManager::InternalExecuteCmd(hr:0xc1510111)
d:\w7rtm\base\ntsetup\opktools\dism\providers\wimprovider\dll\wimmanager.cpp:516 - CWimManager::ExecuteCmdLine(hr:0xc1510111)

解决

去掉WIM镜像文件的只读属性。

WinPE4.0运行.NET程序报错:The subsystem needed to support the image type is not present(支持此镜像类型所需的子系统不存在)

感謝您致電微軟技術支援中心。我是台灣微軟技術支援工程師 ***,很榮幸有機會為您服務。關於您遇到的問題,請參考以下報告。若步驟中有任何不清楚或需要進一步的協助,為避免我們因在電話中而耽誤接聽您電話的時間,建議您先以 EMAIL 方式回覆給我,我將在收到您的來信後儘速與您連絡,謝謝。
問題代號 : 113022310239333
問題說明 : [OS]Prof/Windows 8/在Win 8 64bit PE安裝.NET Framework 4.0程式之後出現“The subsystem needed to support the image type is not present”
解決方式 :
我看到您的錯誤訊息是:
The subsystem needed to support the image type is not present
 
我們認為出現此錯誤訊息應已成功安裝NetFX4,而無法運行的原因是因為版本不符合所導致,您可以先參考下列做法:
 
Error: “The subsystem needed to support the image type is not present”
This error is caused by running a 32-bit version of USMT within a 64-bit WinPE image. There are two rather obvious solutions to this:
1. Use an x86 version of WinPE when running an x86 version of USMT.
2. Use an x64 version of WinPE when running an X64 version of USMT.
It’s fine to use x64 WinPE and USMT to run a scanstate on an x86 offline OS. Always remember to specify the environment variable for the offline OS architecture being scanned. This variable is:
MIG_OFFLINE_PLATFORM_ARCH=<32 or 64>
For example, if the offline OS being scanned was 32-bit Windows XP, you would specify the following in the WinPE command prompt that is about to run scanstate:
SET MIG_OFFLINE_PLATFORM_ARCH=32
 
另外:
Windows PE上的.net framework 並非跟一般Windows 8上的功能完全一樣,有下列限制:

Microsoft .NET

WinPE-NetFX4

New for Windows 8. WinPE-NetFX4 contains a subset of the .NET Framework 4.5 that is designed for client applications.

Not all Windows binaries are present in Windows PE, and therefore not all Windows APIs are present or usable. Due to the limited API set, the following .NET Framework features have no or reduced functionality in Windows PE:



  • Windows Runtime
  • .NET Framework Fusion APIs
  • Windows Control Library event logging
  • .NET Framework COM Interoperability
  • .NET Framework Cryptography Model


 

因此,如果您有使用到以上元件,並非您沒有安裝成功,而是Windows PE上的NetFX4有所限制所導致。
 
參考資料:
 
http://blogs.technet.com/b/askds/archive/2010/02/18/usmt-4-and-winpe-common-issues.aspx
 
http://technet.microsoft.com/en-us/library/hh824926.aspx#bkmk_1

我本机测试了一下。我们的dotnet程序是32位的。而PE是amd64构架的就无法运行。显示”The subsystem needed to support the image type is not present”
我编译了三个.NET程序。分别使用AnyCPU,X86,X64平台配置。只有AnyCPU和X64都可以正常运行,而X86显示不支持。如附件图片所示。

David和Jerry Lin贴出来的命令行都是一样的。但是在所有命令前有一个CopyPE.cmd用来拷贝PE文件,这个命令第一个参数就是指定CPU构架。我估计D****用的是amd64。而J****用的x86 (e.g: CopyPE.cmd x86 c:pe)。

DISM add-package Error 0xc1420127

首先我使用dism把wim mount起来:

dism /mount-wim /wimfile:c:\pe40\media\sources\boot.wim /index:1 /mountdir:C:\pe40\mount

然后就因为其他原因重启动了系统。然后再执行:

dism /image:C:\pe40\mount /add-package /packagepath:"WinPE-WMI.cab"

就报错,错误号是0xc1420127。

解决方法是首先unmount这个wim文件。然后再重新mount。注意mount之后的操作请勿关机或重启。不然就会报错0xc1420127。

You try to mount your wim image and you get this error

Error: 0xc1420127: The specified image in the specified wim is already mounted for read/write access.

When unmount doesn’t work. Try this command: DISM /cleanup-wim

update 2013.03.28:最近使用imagex.exe也报这样的错误。问题原因是同一个wim被重复mount到不同的mount point。一个wim文件同一时间是不能mount到不同的挂载点的。

A failure occurred trying to determine the architecture of DISM in the image.CDISMManager::CreateImageSessionFromLocation(hr:0x801f0005)

I ran the following DISM command to add package for WinPE image:

dism /image:C:\pe40\mount /add-package /packagepath:"WinPE-WMI.cab"

But error occurred:

DISM Manager: PID=1484 TID=6280 A failure occurred trying to determine the architecture of DISM in the image. - CDISMManager::CreateImageSessionFromLocation(hr:0x801f0005)
DISM.EXE: Could not load the image session. HRESULT=801F0005

After google for several hours but in vain.

Finally I realized that I've installed the WimFltr drivers for Vista WAIK for several days. So I removed the file at c:\windows\inf\wimfltr.inf and c:\windows\system32\drivers\wimfltr.sys. And then I delete the registry item at HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\WimFltr. The last step, reboot computer.

Problem solved!

From this case, we can probably know that Wim Filter Driver for different OS cannot be co-existed. Like the WimFltr for Vista WAIK && WimMount for WinPE 4.0(Win8PE).