[英]Reboot & continue batch script
Below is the script created for increasing the swaps & mounting the driver. 以下是为增加交换次数和安装驱动程序而创建的脚本。 Now in this script I want to add the feature that after setting the page file the system will be rebooted & once reboot is done, it will resume with next step which is mounting driver.
现在,在此脚本中,我想添加一个功能,即在设置页面文件后,系统将重新启动,一旦完成重新启动,它将继续进行下一步,即安装驱动程序。 Can you please help in this.
您能帮上忙吗?
@echo off
wmic pagefileset create name="D:\pagefile.sys"
wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=20480,MaximumSize=25480
echo "Pagefile created.
Need to add script to reboot the windows & after reboot continue with next step 需要添加脚本来重启Windows,重启后继续下一步
DISKPART /s C:\Users\Desktop\param_files\instructions.txt
echo "Drive mounted successfully"
Regards 问候
You could mark where you want to restart your script like: 您可以标记要重新启动脚本的位置,例如:
@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
NOTE: The /f
is not really needed in the reg add
command. 注意:
/f
在reg add
命令中并不是真正需要的。
EDIT: Adapting my answer to your specific should look like: 编辑:根据您的具体情况调整我的答案应如下所示:
@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.