Creating a shortcut with two files names one being variable?
-
07-06-2021 - |
Question
I want to create a shortcut that calls two files, first, it calls Excel.exe, then it calls my add-in.
I tested it doing the following:
Target:
"C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "C:\MyAddin.xll"
And it works fine. Now I want to implement it in inno-setup.
I have to get the Excel.exe location via some automation in inno-setup, which I store in a global variable.
This is what I've tried:
Name: {commondesktop}\{#MyAppName}; Filename: ExcelExecutablePath;
Parameters: {app}\{#MyAppExeName}; Tasks: desktopicon;
Flags: CreateOnlyIfFileExists; IconFilename: {app}\Icons\TimeCard64.ico;
I've tried other things too, but I'm at a bit of a loss on this one.
Thanks in advance. Let me know if I should be more clear on something!
Solution
To find the location of 'excel', you can query the 'App Paths' registry key if it includes 'excel.exe' in a function in code section. Example:
[Icons]
Name: "{commondesktop}\My Excel File"; Filename: "{code:GetExcelPath}"; Parameters: """C:\MyAddin.xll"""
..
[Code]
function GetExcelPath(dummy: string): string;
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe', '', Result);
if Result = '' then
Result := 'excel.exe';
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow