bat script to open a PDF when a user logs in

is it possible to have a script open a PDF when a user logs in?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Rob WilliamsConnect With a Mentor Commented:
The problem with providing the application and path is it can vary from machine to machine, 32 vs 64 bit machines, and Acrobat versions.  Though you cannot force it to open in full screen a batch file deployed within the user's profile or group policy only needs to contain:

rem Check if read
If Exist C:\Temp\Counter.txt GoTo END
Echo pdf read >C:\Temp\Counter.txt
rem Open document

(the local directory, Temp in this case, must exist or create it with the batch file.  You cannot write to the root of the drive)

You can also display messages at logon using Group Policy.  They are however limited to about 500 characters
Dan CraciunConnect With a Mentor IT ConsultantCommented:
Why don't you simply put a shortcut to that PDF in the user's startup folder?

Try this route :
Windows\Start Menu\Programs\Startup\

bat file (saved in the location above)

Acrord32.exe /A "zoom=100" "filename.pdf"
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

NxJNYAuthor Commented:
its an awesome idea Dan. is it possible to get a script to create shortcuts of that PDF.

Here is what i am trying to accomplish

we are upgrading users to the new Windows 8.1 update, after they have updated and logs back into their PC we have a PDF that shows all the new features, we would like that PDF to automatically open once per user
NxJNYAuthor Commented:
looking into your solution becraig
If the Acrobat version is consistent then you can simply

create your bat file something like this:

cd %ProgramFiles%\path-to-acrobat
Acrord32.exe /A "zoom=100" "filename.pdf"

Save the above file and push it out to:
Windows\Start Menu\Programs\Startup\ on the clients in question.

If this works for you , be sure to split the points with Dan, since he seemed to be going down the same path before I commented.
NxJNYAuthor Commented:
this is what my script looks like but it does not work

Acrord32.exe /A "zoom=100" "\\myserver\Share\Win8PDF\win8.pdf"
Dan CraciunIT ConsultantCommented:
@becraig: Nope, I wasn't going down that path.

You're assuming that everyone has Adobe Reader installed. That may or may not be the case.

What I was suggesting was more low tech: create a shortcut to the UNC path of the pdf, then push that shortcut/lnk file to the startup path of the computers.

This should trigger the default pdf reader to open that pdf, without the need to check what is that and where it's installed.

Joe Winograd, EE Fellow 2017, MVE 2016, MVE 2015DeveloperCommented:
Could be because <Acrord32.exe> is not in the path. There are numerous ways to solve this. One way is to fully qualify it in the script, such as:

"c:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /A "zoom=100" "\\myserver\Share\Win8PDF\win8.pdf"
Joe Winograd, EE Fellow 2017, MVE 2016, MVE 2015DeveloperCommented:
Oops...I submitted my comment before seeing Dan's post...his idea is better. But there's also an issue that no one has addressed yet. You said, "...we would like that PDF to automatically open once per user". I take that to mean you want each user to see it just once...not on every login. That means you need some logic to determine if each user has already seen it. Regards, Joe
I have a tested powershell solution that work, also deletes all the files afterwards.

Are you open to using powershell as a part of your process ?
David Johnson, CD, MVPOwnerCommented:
This only shows the item 1 time per user on a particular machine.. Most of the others will show it every logon
if ((test-path $env:localappdata\pdfviewed) -eq $false) {
    start-process \\dc01\newstuff\download.pdf
    New-Item $env:localappdata\pdfviewed -type directory

Open in new window

becraigConnect With a Mentor Commented:
So here is my solution as well

5 parts
1) you create the powershell script on a central share
2) Copy a bat file to all users folder to run on startup
This copies the ps1 file locally and then runs it
3) Create a lnk to the pdf on the network then sleep (while programs continue to load.)
4) Load the pdf file
5) Delete the local ps1 and the bat file and the lnk file

So you can actually copy the bat files to the home directory of all users
bat file:
copy \\sharelocation\script.ps1 c:\temp
powershell.exe -ExecutionPolicy Bypass  -File c:\temp\crshrt.ps1

Then save the below ps script on a server share
PS Script:
$varpath = Get-Childitem env:APPDATA | %{ $_.Value }
$dirpath = $varpath + "Microsoft\Windows\Start Menu\Programs\Startup"
$batfile = $varpath + "\Microsoft\Windows\Start Menu\Programs\Startup\starter.bat"
$pdffile = "\\uncpath\pdffile.pdf"
start-sleep 40 
invoke-item $pdffile 
start-sleep 40 
Remove-Item $MyINvocation.InvocationName
Remove-Item $batfile

Open in new window

serialbandConnect With a Mentor Commented:
There's a runonce hive key in the Windows registry.  These are cleared once the program has run once.

If you need to set it up for each new user, you could load the HKUSERS hive from the Default User profile and add the program that you wish to run.  This will work for all new users to the system.  If you want it to work on each existing user, you'll need to load each existing user's hive.

If you only have one user per system, you could just edit the runonce entry in the HKLM hive and have it only run once per system.

NxJNYAuthor Commented:
so sorry guys i was out for an emergency.

What if we create some kind of touch file? is that possible
NxJNYAuthor Commented:
this is the script i ended up using after dropping the touch file on the PC

setlocal EnableDelayedExpansion

REM Set the installed flag location
SET FLAG=!TEMP!\win8.1u1.installed.flag.txt

REM Test if installed flag exists
) ELSE (

del /F !FLAG!

All Courses

From novice to tech pro — start learning today.