Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Feb 2007
    Posts
    12

    File association question

    Is there a way to create a new screen in the installation, that lists the possible file associations for my application, so that the end user can check or uncheck them?

    Also - is there a way to add my application to the 'Open With' menu for any file associations (whether they're selected for association or not)?

  2. #2
    Join Date
    May 2000
    Location
    Indigo Rose Software
    Posts
    2,150
    You would need to use a checkbox screen to accomplish this.

    Adam Kapilik

  3. #3
    Join Date
    Feb 2007
    Posts
    12

    Checkboxes - Font Association - farther along

    I've got scripts that correctly work, assigning variables for each filetype checked in the Checkboxes screen.

    then, in the Ready To Install screen - before Screen.Next:
    I have this, for Text Files (using TextFile variable):
    if SessionVar.Get("%TextFile%")=="True" then

    Registry.SetValue(HKEY_CLASSES_ROOT, ".txt", "", "MyAppName", REG_SZ);
    Registry.SetValue(HKEY_CLASSES_ROOT, "MyAppName\\\\shell\\\\open\\\\command", "", SessionVar.Expand("%AppFolder%\\\\MyAppName.exe\\\ "%1\""), REG_SZ);
    Registry.SetValue(HKEY_CLASSES_ROOT, "MyAppName\\\\DefaultIcon", "", SessionVar.Expand("%AppFolder%\\\\MyAppName.exe ,0\\"), REG_SZ);
    end

    However, it still doesn't work - it doesn't associate my application with text files (*.txt files)

    What am I doing wrong?

  4. #4
    Join Date
    Jun 2005
    Posts
    470
    open regedit and check if keys have been created

    if yes, and it still doesn't work, then these are not the correct keys to create.

    To speed up testing first make a .reg file that sets the file associations, and test it until they are properly set - then create & test SF code that makes the same keys.

    imo keys have to be created (for .txt files) under
    HKEY_CLASSES_ROOT\txtfile
    ,not under HKEY_CLASSES_ROOT\.txt, however I'm not sure as I'm on another PC now. Anyway, if you make it with a .reg file, the rest should be easy.

    ---
    BTW I would love to see a feature to manage file associations in the SF7 projects, so that we don't have to set keys through code and care about eventual OS-specific issues when doing this.
    Last edited by pww; 03-04-2007 at 07:06 AM.

  5. #5
    Join Date
    Feb 2007
    Posts
    12

    Just won't work - VERY Frustrated!

    For some reason, I can just NOT get this association deal working and it's driving me crazy having not only learn all this, but to manually run this, without any way to test other than compiling and running the install app:
    I've got a checkbox page, with a .TXT checkbox - lua variable chktxt.

    I found another project showing how to check it, and it is showing correctly, whether checked or not. Here's the code:
    if chktxt then
    Registry.SetValue(HKEY_CLASSES_ROOT, ".txt", "", "MyApp", REG_SZ);
    Registry.SetValue(HKEY_CLASSES_ROOT, "MyApp\\\shell\\\\open\\\\command", "", SessionVar.Expand("%AppFolder%\\\\MyApp.exe\\\"%1\ ""), REG_SZ);
    Registry.SetValue(HKEY_CLASSES_ROOT, "MyApp\\\\DefaultIcon", "", SessionVar.Expand("%AppFolder%\\\\MyApp.exe ,0\\"), REG_SZ);
    end

    I"m thinking it might have something to do with the syntax above, or the number of slashes, which is very frustrating, since I really have no earthly idea on how many slashes to put and where.

    This really should have more automation assigned to it (are you listening?)!!

    I then double click on a text file and it opens in Notepad - NOT what I wanted.
    I'll need to go to some other solution I can't get this working. Please help!
    Last edited by augustwind; 05-13-2007 at 12:33 AM.

  6. #6
    Join Date
    Feb 2007
    Posts
    12

    Here's what I've found so far

    1. the TXTFile registry setting never gets changed from Notepad. I manually changed it, and at least my application opens, when a text file is double-clicked
    2. the paths that get put in the registry are wrong, based on the knowledgebase article, and the other help I've gotten - it puts 2 slashes in the path before myApp.exe and it messes with the %1% that's supposed to be in there - - don't know for sure, but I don't think that needs to have quotes around it.
    3. the default Icon never gets changed, and it must be what gets put in the path there also, that's the problem, but I don't know what the registry is supposed to have in it for that value.

    I just need a definitive script - I've been fiddling with this on and off for over 3 months now - and that's totally ridiculous - I need a complete solution for a file association!

  7. #7
    Join Date
    Apr 2007
    Location
    Mar Sara
    Posts
    292
    Code:
    --[[
    Function: SetFileAssociation
    Purpose: A function that will create file associations.
    Arguments:
    strApplicationPath - The path to the application executable file.
    strIconFile - The path to the application icon file.
    strFileExtension - The extension to associate.
    Returns: Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
    Example: SetFileAssociation(_SourceFolder .. "\\" .. _SourceFilename, String.Replace(_SourceFolder .. "\\" .. _SourceFilename, ".ico", ".exe", false), ".ogg", );
    ]]--
    function SetFileAssociation(strApplicationPath, strFileExtension, strIconFile)
    	Registry.SetValue(HKEY_CLASSES_ROOT, strFileExtension, "", File.GetShortName(strApplicationPath));
    	Registry.SetValue(HKEY_CLASSES_ROOT, strAppShortName.."\\shell\\open\\command", "", "\""..strApplicationPath.."\" \"%1\"");
    	Registry.SetValue(HKEY_CLASSES_ROOT, strAppShortName.."\\DefaultIcon", "", File.GetShortName(strIconFile)..",0");
    end
    I made this for AMS, but should work on SUF, too.

  8. #8
    Join Date
    Feb 2007
    Posts
    12

    a little more help please

    OK - please help me with understanding the example -- subsitute c:\windows\system3\Notepad.exe and .txt files in the following example line:
    Example: SetFileAssociation(_SourceFolder .. "\\" .. _SourceFilename, String.Replace(_SourceFolder .. "\\" .. _SourceFilename, ".ico", ".exe", false), ".ogg", );

  9. #9
    Join Date
    Apr 2007
    Location
    Mar Sara
    Posts
    292
    Here it is:

    Code:
    SetFileAssociation("c:\\windows\\system3\\Notepad.exe", "c:\\windows\\system3\\Notepad.exe", ".txt", );

  10. #10
    Join Date
    Feb 2007
    Posts
    12

    I get an error message -

    a couple of questions here -
    the way you have the example of notepad, the arguments are in a different order than the function - - is that still right?

    I moved them around, in what I thought would be right, placing the .txt extension in the middle of the call to the function -

    However I get an error:
    On Next, Line 7: attempt to concatenate global 'strAppShortName' (a nil value)
    Also - what's with the red periods in the function?

    Plus - where in the arguments am I supposed to set the appshortname? I ended up hardcoding it in - here's what I ended up with in the functioN:
    function SetFileAssociation(strApplicationPath, strFileExtension, strIconFile)
    Registry.SetValue(HKEY_CLASSES_ROOT, strFileExtension, "", File.GetShortName(strApplicationPath));
    Registry.SetValue(HKEY_CLASSES_ROOT, "iWrite Professional\\shell\\open\\command", "", "\""..strApplicationPath.."\" \"%1\"");
    Registry.SetValue(HKEY_CLASSES_ROOT, "iWrite Professional\\DefaultIcon", "", File.GetShortName(strIconFile)..",0");
    end

    I don't get the 'strIconfile' either - does it get the default Icon from the EXE?



    You do know that your original sample call has much more syntax/arguments than what you gave me in the last post, right?


    Here's what I put in the actual call:
    SetFileAssociation("%AppFolder%\\MyApp.exe", ".txt", "%AppFolder%\\MyApp.exe");

    Still - it doesn't work - and it doesn't change HKEY Root's TXTFile designation
    I double click on a file - it opens up Notepad.

    I'll admit that I don't really know the ends and outs of this action scripting language, but this seems to be really more complicated than it should be. I'm beginning to hate having to learn another language just to do this one thing.

  11. #11
    Join Date
    Jun 2007
    Posts
    5

    Code Edit

    In case anybody runs across this like I did trying to set File extensions in SUF, the function given by Desolator works but it needs a few modifications. This is what I changed to get it working:

    Code:
    function SetFileAssociation(strApplicationPath, strIconFile, strFileExtension)
    	Registry.SetValue(HKEY_CLASSES_ROOT, strFileExtension, "", File.GetShortName(strApplicationPath));
    	Registry.SetValue(HKEY_CLASSES_ROOT, File.GetShortName(strApplicationPath).."\\shell\\open\\command", "", "\""..strApplicationPath.."\" \"%1\"");
    	Registry.SetValue(HKEY_CLASSES_ROOT, File.GetShortName(strApplicationPath).."\\DefaultIcon", "", File.GetShortName(strIconFile)..",0");
    end
    This will solve the problem of the following error:
    "attempt to concatenate global 'strAppShortName' (a nil value)"

  12. #12
    Join Date
    Sep 2004
    Posts
    89
    I am finding that when using %AppFolder% in a script to create a registry key, it is not being converted. It still reads as %AppFolder% for example...

    Registry.SetValue(HKEY_CLASSES_ROOT, "NewType.Document\\shell\\open\\command", "NoName", "%AppFolder%\\NewTypeReader.exe \"%1\"", REG_SZ);

    ends up in the registry as...

    %AppFolder%\NewTypeReader.exe "%1"

    %AppFolder% is not translated??

    What's missing here?

  13. #13
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    Quote Originally Posted by artistscope View Post
    I am finding that when using %AppFolder% in a script to create a registry key, it is not being converted. It still reads as %AppFolder% for example...

    Registry.SetValue(HKEY_CLASSES_ROOT, "NewType.Document\\shell\\open\\command", "NoName", "%AppFolder%\\NewTypeReader.exe \"%1\"", REG_SZ);

    ends up in the registry as...

    %AppFolder%\NewTypeReader.exe "%1"

    %AppFolder% is not translated??

    What's missing here?

    You need to use SessionVar.Expand() or concatenate the strings with SessionVar.Get()


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  14. #14
    Join Date
    Mar 2008
    Posts
    30

    Help a newbie

    I'm trying to use the function set up for creating associations. Here's my code from the post install area:

    setfileassociations ( SessionVar.Expand("%AppFolder%").."amwin.exe",Sess ionVar.Expand("%AppFolder%").."amwin.exe",".am");


    This doesn't cause any syntax errors, but gets the dreaded 'nil value' error when I try to run my install. I'm sure I've overlooked something obvious- any ideas?

    I'm really surprised creating file associations isn't built into the program! Oh well.

  15. #15
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    Quote Originally Posted by wunder View Post
    I'm trying to use the function set up for creating associations. Here's my code from the post install area:

    setfileassociations ( SessionVar.Expand("%AppFolder%").."amwin.exe",Sess ionVar.Expand("%AppFolder%").."amwin.exe",".am");


    This doesn't cause any syntax errors, but gets the dreaded 'nil value' error when I try to run my install. I'm sure I've overlooked something obvious- any ideas?

    I'm really surprised creating file associations isn't built into the program! Oh well.
    Since I don't know what "THE" dreaded 'nil value' error" is -- nor where you are getting that error... my best guess is:
    do you really mean for it to translate to:
    setfileassociations( "c:\program files\some diramwin.exe", "c:\program files\some diramwin.exe", ,".am")

    ??? Shouldn't be "c:\program files\some dir\amwin.exe"?
    SessionVar.Expand( "%AppFolder%\\amwin.exe") is the better way to go.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Best way to share custom buttons with the group?
    By mwreyf1 in forum AutoPlay Media Studio 6.0
    Replies: 10
    Last Post: 04-28-2010, 01:29 PM
  2. Error 3038: Could not seek in compressed file
    By Rikard in forum Setup Factory 7.0
    Replies: 2
    Last Post: 05-25-2006, 11:55 AM
  3. HOWTO: Create a File Association
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-04-2002, 02:37 PM
  4. Replies: 0
    Last Post: 08-17-2000, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts