用于Dell更新的批处理文件-文件浏览器



我目前有一些代码可以静默安装所有Dell更新,但如果最终用户找不到Dell更新程序msi,我希望它能够浏览。我很接近,但在您通过浏览选项选择文件后,它似乎不喜欢其中一个引号或其他内容。有人能帮忙吗?

@echo off
SET file="S:SoftwareDell Command UpdateDellCommandUpdate.msi"
if exist "C:Program Files (x86)DellCommandUpdatedcu-cli.exe" goto:skipinst
if exist %file% goto:instdellupd
echo Please navigate to the DellCommandUpdate.msi file
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "file=%%p"
:instdellupd
echo Installing Dell Command Update app
start %file% /quiet
:skipinst
echo Running the Dell Command Update app
"C:Program Files (x86)DellCommandUpdatedcu-cli.exe" /ApplyUpdates
pause

{未经试验的}

set命令中;逃逸;每个<>前面加一个插入符号^

完成此操作后,for /f中引用的命令本身就会被解析,因此您实际上然后需要分别转义<>^

这意味着,例如,每个<都需要是^^^<,以允许两个级别的解析。

我设法让它工作起来。这是我的最后一个代码:

@echo off
cls
SET file=S:SoftwareDell Command UpdateDellCommandUpdate.msi
if exist "C:Program Files (x86)DellCommandUpdatedcu-cli.exe" goto:runDellUpdater
if exist "%file%" goto:installDellUpdater
echo Please navigate to the DellCommandUpdate.msi file
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "file=%%p"
:installDellUpdater
echo Installing Dell Command Update app
"%file%" /quiet
:runDellUpdater
echo Running the Dell Command Update app
"C:Program Files (x86)DellCommandUpdatedcu-cli.exe" /ApplyUpdates
pause

如果有人感兴趣,您可以直接从Dell下载Dell命令更新自解压exe,在它解压后,在您点击关闭之前,浏览到%temp%以找到msi,复制它,然后您可以使用我的上述代码帮助在任何Dell机器上部署和执行Dell更新程序。它将以静默方式安装它找到的所有更新。

最新更新