如何在不停止 CMD 批处理文件的情况下打开程序?

如何在不停止 CMD 批处理文件的情况下打开程序?

如何关闭批处理脚本窗口而不先关闭已打开的 PDF 文件?即使exit窗口保持打开状态,直到我关闭 PDF 文件。

@echo off
setlocal enabledelayedexpansion
rem query the registry to get the full path to acrobat
for /f "usebackq tokens=3*" %%a in (`reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ /s /f \Acrobat.exe ^| findstr Default`) do (
  set _acrobat=%%a %%b
  rem create the shortcut
  "!_acrobat!" /A "page=10" "file.pdf"
  )
endlocal
exit

答案1

此命令不会停止您的批处理文件:

start "" "%userprofile%\desktop\acrobat.exe.lnk" /A "page=10" "file.pdf"

@rem Windows 10 64-bit. Query registry.  Make link to acrobat.  Open .pdf w/o stopping the batch
@echo off
setlocal enableextensions
for /f "usebackq tokens=3*" %%a in (`reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ /s /f \acrobat.exe ^| findstr Default`) do set zacrobat=%%a %%b
REM Make link
mklink "%userprofile%\desktop\acrobat.exe.lnk" "%zacrobat%" 
REM Open .pdf without stopping batch
start "" "%userprofile%\desktop\acrobat.exe.lnk"  /A "page=10" "file.pdf"
exit /b 

相关内容