Resume batch script after computer restart

前端 未结 4 863
迷失自我
迷失自我 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 07:51

    I know its a bit old but this works amazingly:

    @echo off
    call :Resume
    goto %current%
    goto :eof
    
    :one
    echo two >>myfile.cmd
    ::REBOOT HERE
    goto :eof
    
    :two
    echo resumed here
    goto :eof
    
    :resume
    rem THIS PART SHOULD BE AT THE BOTTOM OF THE FILE
    set current=one
    
    0 讨论(0)
  • 2021-01-01 08:01

    You could put the second command in a exclusive batch file, and add an entry to regedit to execute this batch file automatically upon Windows' start, making silverlight be executed after the computer restarts.

    Have you heard of msconfig? On some systems the regedit PATH you are looking for is:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    

    But you may want to check that. If you want to make a batch file to write that key on the registry, you probably should take a look at this tutorial.

    0 讨论(0)
  • 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
    )
    
    0 讨论(0)
  • 2021-01-01 08:07

    If you do the IE6 installation with the command ie6setup.exe /q /r:n then it won't reboot automatically (see this page for details). Then theoretically you could install SilverLight immediately, and then reboot afterwards; but there is a chance that the SL install will refuse due to the need of a reboot, but it won't hurt to try it...

    0 讨论(0)
提交回复
热议问题