简体   繁体   中英

How to open PDF from C# application running as an administrator

I have an C# windows forms application ( .Net 4 client profile) which needs to run as an administrator.

For that I have added the manifest file and it runs fine.

The problem I am facing is when I want to open a PDF file (Help file) from the application on click of a button.

I have following code to do it.

Process.Start("<FullyQualifiedPath>\Help.pdf");

The code executes without any exceptions thrown. But the Adobe reader process just sits as background process in the task manager, it does not really opens up the file!

If you run the same code without running the parent application under administrator privileges, then the pdf file opens up just fine.

  1. Operating systems I have tried this on are Windows 8 and Windows 7

  2. File does exist on the file system

  3. I have tried opening the file by specifying it as an argument to both "cmd.exe" and "explorer.exe", saw the same behavior in both the cases.

Turns out that you can use the "Windows explorer" to open it. Since "explorer.exe" is not under UAC.

So I tried this and it worked!

Process.Start("explorer.exe","<FullyQualifiedPath>\Help.pdf");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM