0

目前,我有一组必须安装在 Windows 机器上的软件安装(及其路径)。我现在要做的是——每次点击运行并输入软件安装路径。

我想要的是设计一个批处理文件,它将在每次成功安装后安装所有应用程序并重新启动我的系统,然后继续列表中的 NEXT 项。是否可以使用 .bat 文件?

4

1 回答 1

1

这真的不是批处理设计的,所以这会有点hacky。它无论如何都不优雅,但试一试,它可能对你有用。

for /f %%a in (C:\files.txt) do (
start /wait %%a
exit /b
)
for /f "skip=1" %%b in ("C:\files.txt) do (
echo %%b >>C:\newfiles.txt    
)
xcopy C:\newfiles.txt C:\files.txt /y
del C:\newfiles.txt /f /q
shutdown /r /t 0 /f

这个想法是你有一个文本文件,其中包含要安装的可执行文件的路径。它将遍历并执行列表中的第一个文件,等待它完成,然后在没有刚刚安装的文件的情况下重新写入列表。

This is dependend on the setup file having no user interaction and exiting by itself, or maybe it's just to make things easier - in which case just go through each install yourself, and when it finishes the batch file will do the rest.

On the note of rebooting and continuing you will either need to run the batch file again yourself or put it in the registry to start up itself, the latter command being

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v "MyBatchInstaller" /d "C:\MyBatchFile.bat" /f

Hope this helps

于 2012-07-04T14:02:45.943 回答