Process.Start(/* path to pdf */) doesn't work with Adobe Reader on Windows 8

橙三吉。 提交于 2019-12-05 00:50:23

In our case, the problem was only reproducible when starting the application from Visual Studio - starting the .exe directly works as expected.

After some debugging, it turned out that Visual Studio was set to always run as administrator, which causes the issue. Turning this off (which is hard enough itself) fixes the problem.

Still not sure why this happens, though.

Here is how I do, there may be a way to recover the exact path to AcroRd32.exe from Registry although :

String pathToAcroRd32 = Environment.GetEnvironmentVariable("ProgramFiles") + ((Environment.Is64BitOperatingSystem) ? @" (x86)\" : @"\") + "Adobe\Reader 11.0\Reader\AcroRd32.exe";
ProcessStartInfo adobeInfo = new ProcessStartInfo(pathToAcroRd32, _pathToPDFFile);
Process.Start(adobeInfo);

Depending also on the version of Acrobat Reader to launch (if different from Adobe Reader 11.0) you may have to change the path.

Maybe try something like this? I tried you code on Windows 8 with Adobe Reader 11 and it seems to work fine for me. Maybe something else is wrong on the machine in question?

var process = new Process();
process.StartInfo = new ProcessStartInfo(@"Path to your PDF.pdf");
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = true;
process.Start();
qxg

First, you must check if Adobe Reader is the default program for pdf files. You can check it in Control Panel -> Programs -> Default Programs -> Set Associations.

If Adobe Reader is the default PDF program, your code should work on Windows 8, actually in most version of Windows.

If Adobe Reader is not the default PDF program, you need must get path to AcroRd32.exe. This post should help you. Then just execute code in Hybris95's answer.

I don't see your full code, but I solved similar issue by setting ProcessStartInfo.UseShellExecute to true.

Wesley

I still have this problem, can't make the AcroRd32.exe to open, just stays there in the task manager. A possible solution is choosing chrome.exe to start the PDF.

Like this:

var p = new Process
{
    StartInfo = new ProcessStartInfo(@"chrome.exe",  path)
    {
        WindowStyle = ProcessWindowStyle.Maximized
    }
};

p.Start();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!