Resume batch script after computer restart

前端 未结 4 881
迷失自我
迷失自我 2021-01-01 07:21

I have a bunch of old machines running Windows 2000 Pro and IE 5.0 which I want to upgrade to IE 6 with Silverlight. I downloaded the IE6 and Silverlight installers from Mi

4条回答
  •  攒了一身酷
    2021-01-01 08:03

    Based on Tim's post which, when tested, appended "two" to the batch file resulting in a failure to find the batch label "onetwo", so amended to read & write the "current" variable from a seperate text file, leaving the batch file untouched;

    @echo off
    call :Resume
    goto %current%
    goto :eof
    
    :one
    ::Add script to Run key
    reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v %~n0 /d %~dpnx0 /f
    echo two >%~dp0current.txt
    echo -- Section one --
    pause
    shutdown -r -t 0
    goto :eof
    
    :two
    echo three >%~dp0current.txt
    echo -- Section two --
    pause
    shutdown -r -t 0
    goto :eof
    
    :three
    ::Remove script from Run key
    reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v %~n0 /f
    del %~dp0current.txt
    echo -- Section three --
    pause
    goto :eof
    
    :resume
    if exist %~dp0current.txt (
        set /p current=<%~dp0current.txt
    ) else (
        set current=one
    )
    

提交回复
热议问题