View Single Post
  #6  
Old 29-09-2021, 21:15
L33THAK0R's Avatar
L33THAK0R L33THAK0R is offline
Registered User
 
Join Date: Feb 2021
Location: Saudi Arabia
Posts: 406
Thanks: 138
Thanked 117 Times in 70 Posts
L33THAK0R is on a distinguished road
Just as a preface, I originally posted this in the "ASIS" thread, but I reckon it might be more applicable here.

So I have a handful of repacks which have selective installs for a collection of titles, with each having its own shortcut to be placed on the users Desktop, should they select this as an option. Currently however, regardless of the end-users selection a shortcut for each entry made for the application is placed on the desktop, even if the target file is not present. It's not a critical issue but it is a slight annoyance.

My proposed solution, as detailed below, was to use a function named "RemoveShortcut", which is used for the uninstaller generated for a given install, as can be seen here:

Code:
[UninstallDelete]
Type: filesandordirs; Name: {app}
#sub RemoveShortcut
  #emit "Type: Files; Name: ""{userdesktop}\" + Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ShortcutName", "")) + ".lnk"";"
  #emit "Type: Files; Name: ""{userprograms}\" + Trim(ReadIni(SourcePath + "\Settings.ini", "Settings", "ShortcutName", "")) + "\" + Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ShortcutName", "")) + ".lnk"";"
#endsub
#for {i = 1; Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ShortcutName", "")) != ""; i++} RemoveShortcut
However this doesn't seem to work, with testing of 2 dummy data files (each housing its own target application, as well as a blank file to be used as a indicator that the selected component was present), demonstrating both shortcuts were removed even when installing only one of the selected components. If anyone has any thoughts on this I'd love to hear them. I initially thought I might be able to use a series of batch scripts instead, with one script for the removal of each component to be run post-install present in a "main" data file, with a given components archive having an identical, but blank script to overwrite the valid script, however I found I wasn't able to consistently CD to the userdesktop, since I didn't initially take into account a user having a desktop location at a location outside of their C: drive.

__________________________________________________ __________

ORIGINAL QUESTION:


Hi all,

Got a small question regarding whether my proposed solution could work at all (I'm terribly new to pascal/delphi). I've got a fair few packs that feature selective, multiple-title offerings to the end-user, each with their own, separate executable to launch from (since some are emulated and require a small script to launch the ROM), as well as their own entry under the shortcut section of the "Settings.ini" file used in ASIS (baked into a executable thats just a batch script wrapped in an exe). My issue is that regardless of the component selection, upon extraction of all selected archives, all desktop shortcuts defined within the "settings.ini" are generated (should the option be selected).

My current thought process is using the "RemoveShortcut" function, in the Post-install section of the script to delete the shortcut, if a given .txt file is missing (which would be packed with a given selective offering), like so:

Code:
    
#if ("{app}\_CommonRedist\APPS\APP_1.txt" == "0") && ("{userdesktop}\APP_1.lnk" == "1")
 #for {i = 1; Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ShortcutName", "")) != ""} RemoveShortcut
#endif
#if ("{app}\_CommonRedist\APPS\APP_2.txt" == "0") && ("{userdesktop}\APP_2.lnk" == "1")
 #for {i = 2; Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ShortcutName", "")) != ""} RemoveShortcut
#endif
However upon testing this both shortcuts were removed even when installing only one of the selected components. Does anyone have any idea why this might be?
Reply With Quote