2013-07-26 180 views
0

我搜索了2天。现在我在这里,希望能得到帮助。 我想“自动杀死(关闭)”一个文件。 例如:批处理文件...关闭openfiles

关闭@echo TASKKILL/IM Acrord32.exe

那工作正常。唯一的问题是,它关闭了每个PDF文件。但我只想关闭一个特定的文件。 也许通过路径。

所以,我希望任何人都可以帮助我。 (它不必是关闭此PDF文件的批处理脚本,它也可以是工具或其他东西)但它必须关闭文件AUTOMATICALLY。

我希望你能理解我。我不是英语。

到目前为止感谢。 M.L.

+0

是否要关闭特定PDF与给定的文件名,无论何时打开?你能否进一步解释这个任务? – foxidrive

回答

0

为此,您需要“告诉”Acrobat Reader关闭文件。但AFAIK Acrobat Reader不公开任何用于远程控制的API。

我看到的唯一选择是发送一个Ctrl + F4给阅读器,但从命令行是不可能的(至少使用标准命令)。

0

我不确切地知道你的意思,但你要求一个脚本,它会自动关闭Acrord32进程。我的脚本确实如此,但只适用于“暂停”且处理器需求过多的进程。

因此,不需要对注册表,参数或设置Acrobat Reader进行任何更改。批处理脚本默认准备自动杀死进程Acrord32.exe,为此目的已经设计好了,但是脚本可以用来关闭任何其他进程太麻烦的系统,当脚本调用相应的参数时系统会暂停。如果此参数包含带空格的长名称,则必须将该参数括在引号中。例如,在脚本内部,可以确定几个参数的开头。暂停时间,重新检查时间或创建报告的位置(LOG)。脚本关闭所有进程符合任何用户的标准,当然,不是无法关闭的系统。可以在服务器上很有用,很多用户的工作。该脚本已经过优化,以最大限度地减少自身负担的处理器。

谢谢

@echo off 
REM Automatic closing Acrobat Reader or other process parameter specified in the call, which too much high the CPU 
REM Preparing: Artur Zgadzaj 
REM --------------------------------------------------------------------------------------------- 

SET REPEAT_TIME_VERIFICATION_[seconds]=7 
SET IDLE_TIME_[seconds]=5 

SET LOG_FOLDER=C:\UTIL\LOG 



REM # # # #  CHECKING OR IS STARTED AS ADMINISTRATOR  # # # # # 

FSUTIL | findstr /I "volume" > nul&if not errorlevel 1 goto Administrator_OK 

cls 
echo ************************************ 
echo *** RUN AS ADMINISTRATOR *** 
echo ************************************ 
echo. 
echo. 
echo Call up just as the Administrator. Abbreviation can be done to the script and set: 
echo. 
echo  Shortcut ^> Advanced ^> Run as Administrator 
echo. 
echo. 
echo Alternatively, a single run "Run as Administrator" 
echo or in the Schedule tasks with highest privileges 
pause > nul 
goto:eof 
:Administrator_OK 

SET WD=day 
if "%~1"=="" (SET Close_Process=AcroRd32.exe) else (SET "Close_Process=%~1") 
MD %LOG_FOLDER% 2>NUL 
Setlocal EnableDelayedExpansion 

:again 
cls 
echo Automatic closing %Close_Process%, which are charged to the processor too ...&echo.&echo. 

FOR /F "tokens=2,7,8 delims=," %%A IN ('%SystemRoot%\System32\tasklist.exe /v /FO CSV^|find /I ^"%Close_Process%^"') DO (

    SET PROC=%%C 
    SET PROC=!PROC:"=! 

    FOR /F "tokens=2,3 delims=:" %%s IN ("!PROC!") DO (SET PR=%%t 
     if "!PR:~0,1!"=="0" (SET /A PROC_TIME=%%s*60+!PR:~1,1!) else (SET /A PROC_TIME=%%s*60+!PR:~0,2!)) 

    if !PROC_TIME! GTR %IDLE_TIME_[seconds]% (
     SET PID=%%A 
     SET PID=!PID:"=! 

     %SystemRoot%\system32\taskkill.exe /PID !PID! /F 

     SET B=%%B 
     SET B=!B:%USERDOMAIN%\=! 
     SET B=!B:%COMPUTERNAME%\=! 
     SET Process_User=!B:"=! 

     if not "!DATE_WD!"=="%DATE%" ((FOR /F "tokens=1" %%W IN ('POWERSHELL GET-DATE -format dddd') DO SET WD=%%W)&&SET DATE_WD=%DATE%) 
     echo %TIME:~0,8% ^(Hanging: !PROC:~-5!^)   !Process_User! >>"%LOG_FOLDER%\%DATE:-=.% ^(!WD:~0,3!^) Close_%Close_Process%.TXT" 
    ) 
) 

TIMEOUT /T %REPEAT_TIME_VERIFICATION_[seconds]% > nul 
goto again 
相关问题