繁体   English   中英

重新启动并继续批处理脚本

[英]Reboot & continue batch script

以下是为增加交换次数和安装驱动程序而创建的脚本。 现在,在此脚本中,我想添加一个功能,即在设置页面文件后,系统将重新启动,一旦完成重新启动,它将继续进行下一步,即安装驱动程序。 您能帮上忙吗?

@echo off

wmic pagefileset create name="D:\pagefile.sys"

wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=20480,MaximumSize=25480

echo "Pagefile created. 

需要添加脚本来重启Windows,重启后继续下一步


DISKPART /s C:\Users\Desktop\param_files\instructions.txt
echo "Drive mounted successfully"

问候

您可以标记要重新启动脚本的位置,例如:

@echo off

REM Initialization here

if "%~1" neq "" goto :%~1

REM Do some stuff1 here
call :markReboot stuff2

REM Making sure to not execute some part of stuff2 before rebooting
goto :eof 

:stuff2
REM Do some stuff2 here
call :markReboot stuff3
goto :eof

REM ...

:stuffn
REM Do some stuffn here
goto :eof

:markReboot
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /t REG_SZ /d "\"%~dpf0\" %~1" /v  RestartMyScript /f 
shutdown /r /t 0

注意: /freg add命令中并不是真正需要的。

编辑:根据您的具体情况调整我的答案应如下所示:

@echo off

if "%~1" neq "" goto :%~1

wmic pagefileset create name="D:\pagefile.sys"
wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=20480,MaximumSize=25480
echo "Pagefile created. 

call :markReboot stuff2
goto :eof

:stuff2
DISKPART /s C:\Users\Desktop\param_files\instructions.txt
echo "Drive mounted successfully"
goto :eof

:markReboot
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /t REG_SZ /d "\"%~dpf0\" %~1" /v  RestartMyScript /f 
shutdown /r /t 0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM