Really appreciate a little help here.
The pdf is created from an excel sheet which gets updated regularly. However, if the pdf is left open, it will not get updated. So, I would like to put a bat file on the desktop instead of the shortcut to open the pdf file. Then after say 5 mins close the pdf. Therefore if someone forgets to close the pdf, it will close after 5 mins.
Any suggestions would be greatly appreciated.
Thank you
Cionn.
Open a PDF, then close it after 5 mins.
Moderator: DosItHelp
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Open a PDF, then close it after 5 mins.
Off the top of my head,
Although if the batch file is closed, the PDF file will stay open.
Code: Select all
@echo off
start "" "whatever_pdf_reader_you_use.exe pdf_file.pdf"
timeout /t 300
taskkill /F /IM whatever_pdf_reader_you_use.exe /T
Although if the batch file is closed, the PDF file will stay open.
Re: Open a PDF, then close it after 5 mins.
ShadowThief wrote:Off the top of my head,
A small simplification and an extra switch.
Code: Select all
@echo off
start "" "pdf_file.pdf"
timeout /t 300 /nobreak
taskkill /F /IM whatever_pdf_reader_you_use.exe /T
Re: Open a PDF, then close it after 5 mins.
Thank you ShadowThief & foxidrive for your help. If anyone is interested, here's my solution.
I created a bat file using ShadowThiefs code.
I found the /FI caused some problems but don't know why. So I tried just /F & it worked...
This worked fine but the CMD window remains open for 600 secs.
So I created a vbs file to run the bat file...
This works great, & the cmd file remains hidden. But I didn't like the icon, so I created a shortcut & changed its icon.
One other problem I encountered was the Windows Open File - Security Warning. This only happened when I created the files on my desktop, then pasted them to the appropriate folder. If I create the files in the appropriate folder, no security warning.
Thanks a lot for your help
Cionn.
I created a bat file using ShadowThiefs code.
I found the /FI caused some problems but don't know why. So I tried just /F & it worked...
Code: Select all
@echo off
start "" "SomeDrive:\Somefolder\MyFile.pdf"
timeout /t 600
taskkill /F /IM AcroRd32.exe
This worked fine but the CMD window remains open for 600 secs.
So I created a vbs file to run the bat file...
Code: Select all
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "SomeDrive:\Somefolder\MyBatFile.bat" & Chr(34), 0
Set WshShell = Nothing
This works great, & the cmd file remains hidden. But I didn't like the icon, so I created a shortcut & changed its icon.
One other problem I encountered was the Windows Open File - Security Warning. This only happened when I created the files on my desktop, then pasted them to the appropriate folder. If I create the files in the appropriate folder, no security warning.
Thanks a lot for your help
Cionn.
Re: Open a PDF, then close it after 5 mins.
Cionn wrote:One other problem I encountered was the Windows Open File - Security Warning. This only happened when I created the files on my desktop, then pasted them to the appropriate folder. If I create the files in the appropriate folder, no security warning.
Thanks for the feedback. I corrected the switch that you mentioned in the previous posts so future readers aren't easily misled.
The security warning may be from a permissions issue with the account you are using, or if the file is downloaded from a server then windows blocks the file until it is right clicked where you can find unblock in the properties.
Cionn wrote:I found the /FI caused some problems but don't know why. So I tried just /F & it worked...
FI is a filter switch that allows a choice of criteria when deciding which thing should be killed, and the F switch is used to force the program to close.
The force switch can corrupt data if the program has an open file, as the file is unceremoniously closed, but you are replacing the file so it is of no consequence. The force switch isn't needed for many programs as the program will behave normally and close in a quiet and usual way.