计算机重新启动后恢复批处理脚本

发布于 2024-09-11 08:09:54 字数 389 浏览 8 评论 0原文

我有一堆运行 Windows 2000 Pro 和 IE 5.0 的旧机器,我想将它们升级到带有 Silverlight 的 IE 6。我从微软的网站下载了 IE6 和 Silverlight 安装程序,幸运的是它们都有命令行选项,允许它们在“静默模式”下运行。

我将这两个命令放入 DOS 批处理脚本中并运行它,但 IE6 安装程序需要自动重新启动计算机,因此问题是如何恢复脚本并运行第二个命令(安装 Silverlight)。

我的批处理文件现在非常简单:

ie6setup.exe /Q
silverlight.exe /q

据我所知,批处理文件在重新启动计算机后无法恢复执行。有没有办法让他们这样做?还有另一种方法可以完成我的需要吗?

谢谢

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 Microsoft's web sites and fortunately they both have command line options to allow them to run in "silent mode".

I put the two commands in a DOS batch script and ran it, but the IE6 installer requires makes an automatic computer restart so the question is how to resume the script and run the 2nd command (install Silverlight).

My batch file is very simple right now:

ie6setup.exe /Q
silverlight.exe /q

From what I know, batch files can't resume execution after restarting the computer. Is there a way to make them do that? of is there another way to accomplish what I need.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

沫离伤花 2024-09-18 08:10:01
@echo off

set "_RunOnce=HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce"

rem./ :: if no argument was passed, this line will be ignored, but if so, it will be executed here == ^> & %~1

:1st_command
ie6Setup.exe /Q
shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :2nd_command\"" /f & goto :eof 

:2nd_command
SilverLight.exe /Q
timeout -1 | shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :3rd_command\"" /f & goto :eof 

:3rd_command
Skype-8.92.0.401.exe /VerySilent /NoRestart /SuppressMsgBoxes /DL=1 & goto :eof

可以在不创建或操作附加文件中的读数的情况下完成此操作,只需写入和读取密钥并使用执行中传递的参数来控制相关执行所需的命令,使用 goto 命令作为参数 %1


@echo off

set "_RunOnce=HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce"

rem./ if no argument was passed, below will be ignored, but if so, it will be executed here == ^> & %~1

:1st_command
mode con cols=50 lines=1 | title starting %~1
start "google" /wait "c:\program files (x86)\Google\Chrome\Application\chrome.exe" "stackoverflow.com" /new-tab
timeout -1 | shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :2nd_command\"" /f & goto :eof 

:2nd_command
mode con cols=50 lines=1 | title starting %~1
start "google" /wait "c:\program files (x86)\Google\Chrome\Application\chrome.exe" "meta.stackexchange.com" /new-tab
timeout -1 | shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :3rd_command\"" /f & goto :eof 

:3rd_command
mode con cols=50 lines=1 | title %~1
start "google" /wait "c:\program files (x86)\Google\Chrome\Application\chrome.exe" "www.amazon.com" /new-tab
goto :eof 
@echo off

set "_RunOnce=HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce"

rem./ :: if no argument was passed, this line will be ignored, but if so, it will be executed here == ^> & %~1

:1st_command
ie6Setup.exe /Q
shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :2nd_command\"" /f & goto :eof 

:2nd_command
SilverLight.exe /Q
timeout -1 | shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :3rd_command\"" /f & goto :eof 

:3rd_command
Skype-8.92.0.401.exe /VerySilent /NoRestart /SuppressMsgBoxes /DL=1 & goto :eof

It is possible to do it without creating or manipulating readings in additional files, just writing and reading in the key and using arguments passed in the execution to control the command necessary for the relevant execution, using goto command as an argument %1


@echo off

set "_RunOnce=HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce"

rem./ if no argument was passed, below will be ignored, but if so, it will be executed here == ^> & %~1

:1st_command
mode con cols=50 lines=1 | title starting %~1
start "google" /wait "c:\program files (x86)\Google\Chrome\Application\chrome.exe" "stackoverflow.com" /new-tab
timeout -1 | shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :2nd_command\"" /f & goto :eof 

:2nd_command
mode con cols=50 lines=1 | title starting %~1
start "google" /wait "c:\program files (x86)\Google\Chrome\Application\chrome.exe" "meta.stackexchange.com" /new-tab
timeout -1 | shutdown -r -t 0 | reg add "%_RunOnce%" /v "%~n0" /d "\"%~f0\" \"goto :3rd_command\"" /f & goto :eof 

:3rd_command
mode con cols=50 lines=1 | title %~1
start "google" /wait "c:\program files (x86)\Google\Chrome\Application\chrome.exe" "www.amazon.com" /new-tab
goto :eof 
停顿的约定 2024-09-18 08:10:00

如果您使用命令 ie6setup.exe /q /r:n 进行 IE6 安装,则它不会自动重新启动(请参阅 此页面了解详细信息)。那么理论上你可以立即安装SilverLight,然后重新启动;但是 SL 安装有可能会因为需要重新启动而被拒绝,但尝试一下也没什么坏处......

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...

初懵 2024-09-18 08:10:00

我知道它有点旧,但效果惊人:

@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

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
瘫痪情歌 2024-09-18 08:09:59

您可以将第二个命令放在一个专用的批处理文件中,并在 regedit 中添加一个条目,以便在 Windows 启动时自动执行该批处理文件,从而使计算机重新启动后执行silverlight

您听说过msconfig吗?在某些系统上,您正在寻找的 regedit PATH 是:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

但您可能需要检查一下。如果您想制作一个批处理文件来将该密钥写入注册表,您可能应该看看 本教程

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.

走过海棠暮 2024-09-18 08:09:58

根据 Tim 的帖子,在测试时,将“two”附加到批处理文件,导致找不到批处理标签“onetwo”,因此修改为 read &从单独的文本文件写入“当前”变量,保持批处理文件不变;

@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
)

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
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文