Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1085
  • Last Modified:

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?
0
NxJNY
Asked:
NxJNY
  • 5
  • 4
  • 2
  • +4
4 Solutions
 
Dan CraciunIT ConsultantCommented:
Why don't you simply put a shortcut to that PDF in the user's startup folder?

HTH,
Dan
0
 
becraigCommented:
Try this route :
Windows\Start Menu\Programs\Startup\


bat file (saved in the location above)

Acrord32.exe /A "zoom=100" "filename.pdf"
0
 
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
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
NxJNYAuthor Commented:
looking into your solution becraig
0
 
becraigCommented:
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.
0
 
NxJNYAuthor Commented:
this is what my script looks like but it does not work

Acrord32.exe /A "zoom=100" "\\myserver\Share\Win8PDF\win8.pdf"
0
 
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.

Dan
0
 
Joe Winograd, EE MVE 2015&2016DeveloperCommented:
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"
0
 
Joe Winograd, EE MVE 2015&2016DeveloperCommented:
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
0
 
becraigCommented:
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 ?
0
 
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

0
 
becraigCommented:
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

0
 
Rob WilliamsCommented:
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
"\\Server\Share\File.pdf"
:END
Exit

(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
0
 
serialbandCommented:
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.

https://support.microsoft.com/kb/284193

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.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\(
http://community.kaseya.com/xsp/f/28/t/16982.aspx
0
 
NxJNYAuthor Commented:
so sorry guys i was out for an emergency.

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

@ECHO OFF
setlocal EnableDelayedExpansion

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

REM Test if installed flag exists
IF EXIST !FLAG! (
GOTO EDUCATION
) ELSE (
GOTO END
)

:EDUCATION
\\myserver\myshare\Win8PDF\win8.pdf
del /F !FLAG!
exit

:END
exit
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 5
  • 4
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now