0

我刚刚使用 WinPE 3.0 设置了一个可启动的 UFD,我需要它在启动时自动运行几个脚本。

我想知道是否有人对设置自动脚本以列出本地驱动器上的分区、显示系统日期、列出当前 IP 和捕获本地驱动器的图像有任何建议。

如果有人可以提供帮助,那就太好了!谢谢。

4

2 回答 2

1

Build your scripts independently and test their functionality prior to placing them inside of your WinPE. Then mount your winPE so you can edit it and place all of your scripts in the winPE

Mounting command:

DISM /Mount-WIM /WimFile:C:..[dir of where your wine is located]\ISO\sources\boot.wim /index:1 /MountDir:mount

Then place your scripts inside of a folder inside your mount folder (which now should have stuff inside of it). Once that completed, you can easily call them by modifying the ..\Windows\System32\startnet.cmd file.

NOTE: DO NOT REMOVE the first line wpeinit. Just add after it: start <scriptname.bat or .vbs>

Save and close.

Keep in mind: if you are doing scripts inside of winPE that handles anything with the NIC, you will need to insert the network drivers into your WinPE. Once your winpe loads, it automatically calls startnet.cmd first.

Some tutorials to do so can be located here.

于 2012-07-16T13:31:10.087 回答
0

我在可启动的 WinPE 映像中添加了一个批处理文件来执行其中的许多任务。它首先检查以确保您确实在运行 WinPE(而不是从另一个操作系统运行批处理文件)。

set pVersion=WinPE not found
for /F "usebackq tokens=3" %%A IN (`reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinPE" /v "Version" 2^>nul ^| find "Version"`) do (
set pVersion=%%A
)
echo WinPE Version: %pVersion%
IF /I "%pVersion%"=="3.0" GOTO ContinueProc
IF /I "%pVersion%"=="4.0" GOTO ContinueProc
echo *************************************************************************
echo **  ERROR: This restore batch file can only be used in WinPE version   **
echo **  3.0 and 4.0                                                        **
echo *************************************************************************
GOTO ExitInstall

然后我通过...向用户列出磁盘 0 的磁盘、卷和分区信息...

diskpart /s list.txt

...其中 list.txt 包含...

list disk
list volume
select disk 0
list partition
exit

然后我的批处理文件将清理磁盘 0、格式化驱动器并应用磁盘映像。我使用 imagex 来捕获和应用图像。在您的情况下,您声明您想要捕获磁盘映像,您可以对网络驱动器、另一个硬盘驱动器、USB 硬盘驱动器或 UFD 执行此操作。

例如。

imagex /capture c: y:\mydiskimage.wim "My system disk"

要列出 IP,您只需运行 ipconfig。

如果希望您的批处理文件在启动时自动运行,您可以尝试编辑/创建一个 winpeshl.ini,如果将其添加到 Windows\System32 文件夹将启动自定义进程。

我确保我有 startnet.cmd,然后列出我想要运行的内容。我添加了 setlw.exe(在线搜索)以确保我的 UFD 始终是驱动器号 Y。然后您可以将批处理文件作为最后一项运行。在此示例中,我还添加了 cmd,以便用户在所有操作完成后收到命令提示符。

[LaunchApps]
%SYSTEMDRIVE%\Windows\system32\startnet.cmd
%SYSTEMDRIVE%\Windows\system32\setlw.exe
Y:\sources\mybatchfile.cmd
%SYSTEMDRIVE%\Windows\system32\cmd.exe

注意:我的批处理文件启动的第一个命令之一:

chdir /D %~dp0

...将目录更改为批处理文件的位置。

于 2013-11-28T19:26:35.510 回答