前段时间自己弄了个精简版的PE,只想让它作一件事,就是启动后通过批处理startnet.cmd实现查找最后一个分区snap目录下的备份文件sn.sna,并用snapshot.exe来进行系统恢复,可是startnet.cmd的黑窗口不是太好看,由于startnet.cmd在PE中的特殊性,只要它一退出PE就会重启,所以干脆就想让它美观点吧,就添加了改变窗口大小的语句,可在PE中提示"mode不是有效的外部命令。。。。",意识到可能精简了mode.com,于是拷贝正常运行的mode.com文件到我的pe中,这回不报错了,但窗口还是那个大大的黑窗口,mode.com好像并没有起作用,估计还有其它被精简掉了,网上查了一下没什么收获,所以只好到这里请教下各位,麻烦帮忙操个心,指点指点
附上我的代码,看还有没有优化的空间
@echo off
title 系统恢复
set a=10
:re
set /a a+=1
mode con: cols=%a% lines=3
if %a% lss 42 goto re
echo ------正在恢复系统,您无需任何操作!-------
echo ------恢复进度到 100%% 后会自动重启 -------
for %%b in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%b:\windows\explorer.exe set sd=%%b
for %%a in (i h g f e d ) do (
for /f "delims=" %%i in ('dir /s/a/b/a-d "%%a:\snap\sn.sna" 2^>nul') do (
%%~dpi\snapshot.exe %%~dpi\sn.sna %sd%: -go -y --autoreboot:any
)
)
exit
Last edited by snai9 on 2020-11-16 at 14:39 ]
I made some time ago a stripped-down version of PE. I just wanted it to do one thing: after booting, use the batch file startnet.cmd to find the backup file sn.sna in the snap directory of the last partition, and use snapshot.exe to restore the system. But the black window of startnet.cmd wasn't too nice. Since startnet.cmd is special in PE, as soon as it exits, PE will restart. So I simply wanted to make it look nicer, so I added statements to change the window size. But in PE, it prompted "mode is not a valid external command...", realizing that mode.com might have been stripped down. So I copied the normal mode.com file to my PE. This time there was no error, but the window was still that big black window. mode.com didn't seem to work. I guessed there were other things stripped down. I searched online but didn't find anything. So I had to come here to ask you all for help. Please take some time and give me some pointers.
Attached is my code. See if there's any room for optimization.
@echo off
title System Recovery
set a=10
:re
set /a a+=1
mode con: cols=%a% lines=3
if %a% lss 42 goto re
echo ------System recovery is in progress, you don't need to do anything!-------
echo ------The system will automatically restart after the recovery progress reaches 100%% -------
for %%b in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%b:\windows\explorer.exe set sd=%%b
for %%a in (i h g f e d ) do (
for /f "delims=" %%i in ('dir /s/a/b/a-d "%%a:\snap\sn.sna" 2^>nul') do (
%%~dpi\snapshot.exe %%~dpi\sn.sna %sd%: -go -y --autoreboot:any
)
)
exit
Last edited by snai9 on 2020-11-16 at 14:39 ]