4 Replies Latest reply on May 4, 2011 6:18 AM by acardy

    Starting Adobe Reader with ShellExecute fails

    acardy

      Hi,

       

      When I try and run open a PDF with shell execute and Adobe Reader being the default application, the PDF opens an Adobe Reader and then Reader crashes about five seconds afterwards with a Visual C++ error. I'm trying this in a 64bit Windows 7 enviroment.

       

      From checking process monitor, it looks like Adobe reader is trying to access the systemprofile directories which is being denied. If I give everyone permissions to these folders it works again.

       

      Open the PDF from explorer works fine.

       

      Any help, clues or hints anyone?

       

      thanks a lot!

       

      Andy.

        • 1. Re: Starting Adobe Reader with ShellExecute fails
          arun aneja Level 1

          Hi Andy,

           

          If you disable Protected Mode (Edit -> Preferences -> General -> Uncheck Enable Protected Mode at startup) and launch Reader again, does this problem persist?

           

          Please note that disabling protected mode is just to find out whether problem is with Protected mode or without it as well. It is always advised to run Reader in protected mode as this makes your system more secure.

           

          Thanks,

          Arun

          1 person found this helpful
          • 2. Re: Starting Adobe Reader with ShellExecute fails
            acardy Level 1

            Hey,

             

            I think I've found the root cause and can't easily test the broken code anymore.

             

            I did try running it it compatibility mode originally though and it did solve the problem. It also said that protected mode was disabled when I was running the app in compatibility mode, so I asume that turning off protected mode would also be a work around.

             

            The cause I think was that when using shell execute, the users enviromental variables were not being loaded by Adobe Reader. This is confirmed by checking the Adobe Reader process with process monitor. I could see that Reader was looking in SystemProfile folders to read and write, which of course is not right and quite rightly being denied. I think it was these denials that causes the crash.

             

            My solution is to load the users enviromental block and using StartProcessAsUser instead. This means that Reader gets the right enviroment and starts to look in the users APPDATA folder rather than system profile.

             

            Any comments may be interesting!

             

            Ta,

             

            Andy.

            • 3. Re: Starting Adobe Reader with ShellExecute fails
              arun aneja Level 1

              Hi Andy,

               

              Can you please tell what parametrs exactly are you passing for ShellExecute? We need to replicate the issue at our end.

               

              Thanks,

              Arun

              • 4. Re: Starting Adobe Reader with ShellExecute fails
                acardy Level 1

                Hey,

                 

                Actually, delving deeper, it seems like our situation is actually a bit more complicated as our code was running under a low privilage system user, hence I guess why it was looking at SystemProfile. If I try to open adobe with a PDF specified on command line using ShellExecute or CreateProcess in a sample app it actually works fine, even running as the local user.

                 

                Thanks.