locked
"No application is associated with the specified file for this operation. (Exception from HRESULT: 0x80070483)" : Unable to open image programmatically using AutomationFactory when Paint is default app. RRS feed

  • Question

  • I am facing an issue while trying to open an image file from a Silverlight app in Windows 10 using WScript.Shell.

    The code is as follows.

    try
            {
                dynamic shell = AutomationFactory.CreateObject("WScript.Shell");
                shell.Run(@"C:\temp\X.jpg");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }

    This piece of code works perfectly fine when the default application is set to 'Photos' / 'Internet Explorer' in Windows 10 'Default Apps' settings.

    However, when the default app is set to 'Paint', I get an exception "No application is associated with the specified file for this operation. (Exception from HRESULT: 0x80070483)"

    Please note that when I try to double click on the same image in Windows explorer, it opens up in Paint application without errors.

    Why does this happen? Please help.


    • Edited by praseo Thursday, November 3, 2016 8:31 AM Updated heading for more relevance
    Wednesday, November 2, 2016 7:37 AM

All replies

  • Hi praseo,

    According tested your code snippet in my side, I get the same issue with you. Then I check the difference between Photos/Internet Explorer and Paint, I found that the Photos/Internet are installed in path of "C:\Program Files", which we could uninstall and reinstall these programs manually.

    But the Paint program is installed in "C:\WINDOWS\system32", which means this program is a system component. It could not install and uninstall manually.

    If we want to use the Paint to open an image file with shell.Run(), please modify your code as below. It will open the Paint first and then open the image in Paint.

    dynamic shell = AutomationFactory.CreateObject("WScript.Shell");
    
    shell.Run(@"C:\WINDOWS\system32\mspaint.exe C:\temp\X.jpg");

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, November 3, 2016 6:43 AM
    Moderator
  • Thanks Weiwei for your reply.
    However, the default application could be anything on a client computer.
    Therefore,I would not be able to hard-code the application path.

    Is it possible to find out the reason behind the issue faced?
    As a workaround, we are currently setting 'Photos' as the default application for viewing images.

    Thanks in advance,
    Praseo
    Thursday, November 3, 2016 8:31 AM
  • Hi praseo,

    I have checked the Registry for both of Photos and Paint, they are registred in Registry. I don't find any other difference between them.

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 4, 2016 6:25 AM
    Moderator
  • Any update on this?
    Thursday, November 17, 2016 5:07 AM