Inno setup can not create desktop icon in windows 10


I have setup file for inno setup of latest version. It compiles and works great from windows xp to windows 8, but in windows 10 it fails on the moment when it creates desktop icon with next error: IPersistFile::Save failed; code 0x80070002

This is how I create icon in setup file:

Name: "{userdesktop}\Forex Tester 4"; Filename: "{app}\ForexTester4.exe"; Tasks: desktopicon

Part of the installation log file:

2019-02-01 12:50:46.376   -- Icon entry --
2019-02-01 12:50:46.376   Dest filename: C:\Users\Mike\Desktop\Forex Tester 4.lnk
2019-02-01 12:50:46.376   Creating the icon.
2019-02-01 12:50:46.376   Exception message:
2019-02-01 12:50:46.376   Message box (OK):
                          IPersistFile::Save failed; code 0x80070002.
                          The system cannot find the file specified.
2019-02-01 12:50:59.066   User chose OK.

This folder exists and I can create files there manually. But inno setup fails to do this... All other icons except desktop one were created without problems.

Any ideas?

asked on Stack Overflow Feb 1, 2019 by Mike K.

2 Answers


I had the same error on Windows 7 and Windows 10 because I was trying to create shortcut to file that didn't exist yet.

; Create icons for the app
Name: "{group}\{#AppName}"; \
    Filename: "{app}\{#AppName}.lnk"; \
    BeforeInstall: CreateAppRunLink();
Name: "{commondesktop}\{#AppName}"; \
    Filename: "{app}\{#AppName}.lnk"; \
    Tasks: desktopicon;

So I had to make sure that file "{app}{#AppName}.lnk" exists prior to creating the Icon: This goes to [Code] section:

procedure CreateAppRunLink();
    Filename: string;
    Description: string;
    ShortcutTo: string;
    Parameters: string;
    WorkingDir: string;
    IconFilename: string;
    Filename := ExpandConstant('{app}\MyApp.lnk');
    Description := 'Description';
    ShortcutTo := 'Full path to file that will be run (MyApp.exe)';
    Parameters := 'parameters if any';
    WorkingDir := ExpandConstant('{app}');
    IconFilename := ExpandConstant('{app}') + '\icon.ico';

    CreateShellLink(Filename, Description, ShortcutTo, Parameters, WorkingDir, 
        IconFilename, 0, SW_HIDE);

CreateAppRunLink will will be called after extracting any files from [Files] section which will make sure that our file is in place.

Hope that'll help.

answered on Stack Overflow Feb 5, 2019 by developer • edited Feb 6, 2019 by developer

It could be a relatively new (since version 1709) Windows 10 feature called Controlled folder access. See Allow a blocked app in Windows Security for instructions on turning it on or off.

answered on Stack Overflow Mar 8, 2019 by Ken

User contributions licensed under CC BY-SA 3.0