2

I've just made a batch file that launches a new instance of an application (Excel) and then opens a file with this instance.

However, I would like to be able to store a config file on each users computer that holds a preference setting.

The setting would tell the batch file to either open a new instance, or launch the file with an existing instance of Excel (if available). I'm good on the program flow, just want to know the commands for getting a handle to an open instance of the app. Is this possible using DOS commands, or do I need to look at designing a front loader with Excel or some other program?

4

1 回答 1

2

如果您只执行 Excel 文件怎么办?如果没有 excel 正在运行,则将启动一个实例,如果 excel 正在运行,则使用此 Excel 来查看文件。:)

或者通过 TASKLIST /FI "IMAGENAME EQ EXCEL.EXE" 进行检查可能有助于检查实例是否正在运行:

TASKLIST /FI "IMAGENAME EQ EXCEL.EXE" | FINDSTR /I "EXCEL.EXE" >NUL 2>&1
IF ERRORLEVEL 1 GOTO :NotFound
IF ERRORLEVEL 0 GOTO :Found

亲切的问候

使用 Findstr 和错误处理进行编辑。

于 2014-11-06T06:49:05.703 回答