实现电脑重启指定次数的bat

编程入门 行业动态 更新时间:2024-10-25 16:29:06

    这是无聊时候看了下批处理文档写的,基本上实现了重启电脑的指定次数。缺点是只能放在桌面上跑还有就是不能绕过用户密码。在此只做参考,可以在此基础上继续完善

复制代码用记事本打开,保存为.bat档,使用Administrator运行。


@echo off

echo    Author:Hama_Tago Time:2017/9/5

echo  ====================================
echo  RE:Pelase Runing On The User\Desktop
echo  ====================================

cd "%Userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

if exist 2.txt goto start
if exist log.log del log.log
if exist restart.bat del restart.bat

cd %Userprofile%\Desktop

copy restart.bat "%Userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

:start
  cd %Userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
  if not exist 1.txt goto set 
  if exist 2.txt for /F %%i in (2.txt) do set /a b=%%i 
  set /a b+=1
  echo %b% >2.txt
  for /F  %%i in (1.txt) do set /a c=%%i

   if %b% gtr %c% goto end

::restart
  echo %b% >>log.log
  echo %date% %time% >>log.log
  cd c:\windows\system32
  shutdown -r -t 0

  pause >nul


:end
del 1.txt
del 2.txt
del restart.bat
copy log.bat "%Userprofile%\Disktop"

:set
  echo  ===================================
  echo  [pelase input the times of Restart]
  echo  ===================================  
  set /p a= 
  echo %a% >1.txt
  goto start

更多推荐

实现电脑重启指定次数的bat

本文发布于:2023-06-14 02:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1427627.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重启   次数   电脑   bat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!