简体   繁体   English

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

[英]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. 注意: /freg 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.

相关问题 批处理脚本“继续”循环? - batch script “continue” in loop? 检查是否需要重新启动并在重新启动后继续执行 Powershell 脚本? - Check if a reboot is needed and continue Powershell script after reboot? 批处理脚本后继续使用CMD命令 - Continue With CMD Commands After Batch Script 批处理脚本在异常情况下暂停,可以自动继续吗? - Batch script pauses on exception, possible to continue automatically? 调用powershell脚本后,批处理文件不会继续 - Batch file wont continue after call up a powershell script 批处理脚本 - 如何在出错时暂停(按任意键继续......)? - Batch Script - How to pause (Press any key to continue . . .) on error? 仅在程序启动后才继续批处理脚本 - Continue batch script only after program has booted 从bat文件调用vb脚本后继续批处理代码 - Continue batch code after calling vb script from bat file WinPE Windows 10 成像——无法在批处理脚本中的“暂停”后调用“wpeutil 重启” - WinPE Windows 10 Imaging -- Unable to call 'wpeutil reboot' after 'PAUSE' in BATCH script 使用批处理命令自动连接到FTP服务器,继续执行批处理脚本,然后在必要时运行FTP命令 - Automatically connect to FTP server using batch commands, continue with batch script and then run FTP commands when necessary
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM