很赞!我也正在学习批处理。求分享其它几个批处理。howe58@live.cn
一下是我 写一个批处理, 想实现分区 然后搜索本地系统镜像或者是备份然后安装,无赖还有很多东西没有学懂- @echo off
-
- :menu
- echo -----------菜单选项-----------
- echo 1.磁盘分区
- echo 2.安装系统
- set /p choice=请输入选项:
- if "%choice%"=="1" goto partition
- if "%choice%"=="2" goto install
- goto menu
-
- :partition
- echo 打开 diskgen...
- start diskgen.exe
- echo 等待 10 秒
- ping 127.0.0.1 -n 10 > nul
- echo diskgen 已关闭
- goto install
-
- :install
- setlocal enabledelayedexpansion
- set /a count=0
- for %%d in (C: D: E: F:) do (
- for /r %%f in (%%d\*.iso %%d\*.win %%d\*.esd %%d\*.gho) do (
- if not "%%~xf"=="ghoj" (
- set /a count+=1
- set "path!count!=%%~dpf"
- echo !count!. %%~dpf
- echo %%~dpf>>1.txt
- )
- )
- )
-
- set /p x=请输入要安装的系统编号:
- set y=
- for /f "tokens=1,2 delims=." %%a in ("!path%x%!") do (
- set "drive=%%a"
- set "path=%%b"
- )
- if "%%~xf"==".gho" (
- for %%d in (%drive%) do (
- if exist %%d\%path% (
- set /a count+=1
- set "path!count!=%%~dpd"
- echo 请为还原目录输入编号y:
- set /p y=
- echo ghost32 -clone,mode=load,src=!path%x%!,dst=!path%y%! -sure -rb
- pause
- ) else (
- echo 目录不存在: %%d\%path%
- pause
- )
- )
- ) else (
- if "%%~xf"==".iso" (
- set install_cmd=dism /Apply-Image /ImageFile:!path%x%! /Index:1 /ApplyDir:!path%y%!
- ) else (
- set install_cmd=dism /Online /Add-Package /PackagePath:!path%x%!
- )
- for %%d in (%drive%) do (
- if exist %%d\%path% (
- set /a count+=1
- set "path!count!=%%~dpd"
- echo 请为安装目录输入编号y:
- set /p y=
- echo %install_cmd%
- pause
- ) else (
- echo 目录不存在: %%d\%path%
- pause
- )
- )
- )
-
- exit
复制代码
|