Solved

bat script to open a PDF when a user logs in

Posted on 2014-04-23
16
788 Views
Last Modified: 2014-06-26
is it possible to have a script open a PDF when a user logs in?
0
Comment
Question by:NxJNY
  • 5
  • 4
  • 2
  • +4
16 Comments
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 125 total points
ID: 40018589
Why don't you simply put a shortcut to that PDF in the user's startup folder?

HTH,
Dan
0
 
LVL 28

Expert Comment

by:becraig
ID: 40018601
Try this route :
Windows\Start Menu\Programs\Startup\


bat file (saved in the location above)

Acrord32.exe /A "zoom=100" "filename.pdf"
0
 
LVL 2

Author Comment

by:NxJNY
ID: 40018614
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
 
LVL 2

Author Comment

by:NxJNY
ID: 40018634
looking into your solution becraig
0
 
LVL 28

Expert Comment

by:becraig
ID: 40018646
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
 
LVL 2

Author Comment

by:NxJNY
ID: 40018647
this is what my script looks like but it does not work

Acrord32.exe /A "zoom=100" "\\myserver\Share\Win8PDF\win8.pdf"
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40018689
@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
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 40018767
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 40018777
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
 
LVL 28

Expert Comment

by:becraig
ID: 40018817
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
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40018902
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
 
LVL 28

Assisted Solution

by:becraig
becraig earned 125 total points
ID: 40018958
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
 
LVL 77

Accepted Solution

by:
Rob Williams earned 125 total points
ID: 40019267
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
 
LVL 27

Assisted Solution

by:serialband
serialband earned 125 total points
ID: 40021108
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
 
LVL 2

Author Comment

by:NxJNY
ID: 40074870
so sorry guys i was out for an emergency.

What if we create some kind of touch file? is that possible
0
 
LVL 2

Author Closing Comment

by:NxJNY
ID: 40160675
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now