Announcement

Collapse
No announcement yet.

Setting the destination from a user config OPT file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting the destination from a user config OPT file

    I need a method depending on which radio button is selected to locate the UserCFG.opt file and from there locate the directory inside that file.
    At the end of the usercfg file is...... InstalledPackagesPath "F:\FS2020"

    So first locate file then extract location and create the link.

    radio button options:
    -MSFS 2020 Windows Store version: C:\Users*USERNAME\AppData\Local\Packages\Microsoft .FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg. opt
    -MSFS 2020 Steam version: C:\Users*USERNAME\AppData\Roaming\Microsoft Flight Simulator\UserCfg.opt

    Any help would be appreciated.



  • #2
    your explanation is pretty rough

    anyway try this:
    lnk.apz

    Comment


    • #3
      I am confused. You sent me some audio files? I am looking for code that can look for the file UserCfg.opt always located here.....C:\Users*USERNAME\AppData\Local\Packages\ Microsoft .FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg. opt

      that has the user destination of their sims program.
      And at the bottom of that file is.......InstalledPackagesPath "F:\FS2020"
      And you can see that my file showed i installed the sim to "F:\FS2020"

      So now i need to let setup factory use "F:\FS2020" as the destination.

      So the only way to find this info is to search
      C:\Users*USERNAME\AppData\Local\Packages\Microsoft .FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg. opt

      then read this line... InstalledPackagesPath
      and after that is the destination of their sim folder.

      Hope this helps.

      Comment


      • #4
        dude
        the apz file I sent you looks for the UserCfg.opt files on your HD and sets the path of the 2 files respectively in radiobutton 1 (local) and radiobutton2 (roaming).
        clicking on the radio buttons creates a folder FS2020 in F: and the link to the UserCfg.opt file is created inside the folder



        Page On Show:
        PHP Code:
        function found (filename)
        ListBox.AddItem("ListBox1"filenamefilename);
        return 
        true;
        end
        File
        .Find("C:\", "UserCfg.opt", true, true, nil, found); 

        Radiobutto1 On Click
        PHP Code:
        lnk ListBox.GetItemText("ListBox1"1);
        Folder.Create("F:\\FS2020");
        Shell.CreateShortcut("F:\\FS2020""UserCfg.opt"lnk""""""0SW_SHOWNORMALnil""START_OPTION_DEFAULT); 

        Radiobutto1 On Click
        PHP Code:
        lnk ListBox.GetItemText("ListBox1"2);
        Folder.Create("F:\\FS2020");
        Shell.CreateShortcut("F:\\FS2020""UserCfg.opt"lnk""""""0SW_SHOWNORMALnil""START_OPTION_DEFAULT); 


        in this explanation you have been clearer
        but since you think these are audio files, wait for someone else to help you

        Comment


        • #5
          You should have posted in Discussion forum with an example of your opt file and also your apz.

          herrin has gone to the trouble of giving you a hand but I think he didn't realise the opt file is actually an ini file

          I have done this example for you, see if it comes close to meeting your needs if folders are not there it copies a fake opt file for you to get the path into the listbox
          UserPath.apz

          Comment


          • #6
            Setup Factory does not open *.apz files.

            Ulrich

            Comment


            • #7
              Sorry for placing this in the wrong forum topic. My bad. And thanks everyone for trying to help.

              I will explain this step by step. A code for each step.

              1. Locate the users UserCfg.opt file. (This is located here...C:\Users*USERNAME\AppData\Local\Packages\ Microsoft .FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg. opt)
              2. Read the text after the phrase InstalledPackagesPath (This phrase is at the end of the text and has a link after it.)
              3. The text/link will then be stored into a variable.
              4. Convert that variable into a Sessionvar.Set
              Now from there i can use this Sessionvar as the installer installation location for my new software. This way the user does not have to locate it.

              Comment


              • #8
                Also here is the UserCfg.opt file and you can see the phrase we look for and the link we want to store. Each user will have a different location.
                Also keep in mind this UserCfg.opt file has nothing to do with setup factory and is already in their computer. If they do not have the file then i want to have the destination empty and they can add it them selves.

                Comment


                • #9
                  Also one last note we need to remove the quotes around the link. I am sure you figured that but i want to make that clear.
                  I would really appreciate help as i have learned a lot over the last 2 years about how to write code for this program but some topics i have not done yet like reading strings. Thanks again.

                  Comment


                  • #10
                    If this request is not easy there is another option if it works. We can ask to run this VBScript and store the ReturnCode using File.Run.

                    Code:
                    'Variable declaration filename = "UserCfg.opt" instpath = "InstalledPackagesPath" 'Open the file Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(filename) 'Read the file line by line Do Until f.AtEndOfStream Textline = f.ReadLine If Instr(Textline, instpath) then 'Match the install path string contents = Replace(Textline, instpath, "") 'Remove the InstalledPackagesPath from main string contents = replace(contents, chr(34), "") 'Remove double quote value contents = trim(contents) 'Trim the space WScript.Stdout.Write contents 'Display ouput. Original = WScript.Echo contents end if Loop f.Close 'Close file

                    Comment


                    • #11
                      Easier to read code...

                      Code:
                      '-----------------------------------------------------------------
                      'This script used to read the UserCfg.opt filename
                      'Match "InstalledPackagesPath" string and extract the path value
                      '-----------------------------------------------------------------
                      
                      'Variable declaration
                      filename = "UserCfg.opt"
                      instpath = "InstalledPackagesPath"
                      
                      
                      'Open the file
                      Set fso = CreateObject("Scripting.FileSystemObject")
                      Set f = fso.OpenTextFile(filename)
                      
                      
                      'Read the file line by line
                      Do Until f.AtEndOfStream
                      Textline = f.ReadLine
                      If Instr(Textline, instpath) then 'Match the install path string
                      contents = Replace(Textline, instpath, "") 'Remove the InstalledPackagesPath from main string
                      contents = replace(contents, chr(34), "") 'Remove double quote value
                      contents = trim(contents) 'Trim the space
                      WScript.Stdout.Write contents 'Display ouput. Original = WScript.Echo contents
                      end if
                      Loop
                      f.Close 'Close file

                      Comment


                      • #12
                        UPDATE:

                        I managed to save the vbs file inside the UserCfg.opt folder location.
                        And i am able to run it by hand and it now creates a new text file with the actual link i need. (This is a major step)
                        But now i am attempting to run the vbs file from the installer with no luck. Seems that it only like exe or lua.
                        How can i run a VBS file?

                        Here is my new VBS code incase anyone can write this in lua.

                        Code:
                        'Variable declaration
                        filename = "UserCfg.opt"
                        instpath = "InstalledPackagesPath"
                        
                        
                        
                        'Create a file
                        Const wr = 2
                        Set objFso = CreateObject("Scripting.FileSystemObject")
                        Set oFile = objFso.OpenTextFile("directory.txt",wr,true)
                        
                        
                        
                        'Open the file
                        Set fso = CreateObject("Scripting.FileSystemObject")
                        Set f = fso.OpenTextFile(filename)
                        
                        
                        'Read the file line by line
                        Do Until f.AtEndOfStream
                        Textline = f.ReadLine
                        If Instr(Textline, instpath) then 'Match the install path string
                        contents = Replace(Textline, instpath, "") 'Remove the InstalledPackagesPath from main string
                        contents = replace(contents, chr(34), "") 'Remove double quote value
                        contents = trim(contents) 'Trim the space
                        oFile.Write contents 'Write contents to file
                        end if
                        
                        Loop
                        f.Close 'Close file

                        Comment


                        • #13
                          Got everything working. Sorry some of you could not understand what i was asking for i did not have good info in the beginning as a zip file has nothing to do with what i needed. But thanks for trying to help.

                          My request from a few days ago...

                          1. Locate the users UserCfg.opt file. (This is located here...C:\Users*USERNAME\AppData\Local\Packages\ Microsoft .FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg. opt)
                          2. Read the text after the phrase InstalledPackagesPath (This phrase is at the end of the text and has a link after it.)
                          3. The text/link will then be stored into a variable.
                          4. Convert that variable into a Sessionvar.Set

                          Here is what i did...

                          STEPS 1-2..... I added the VSScript to the primer files so it loads into the TempLaunchFolder. Then on startup i used the Shell.Execute variable to run the VSScript.

                          3. This script now reads the UserCFG.opt locates the info i need and stores the directory i was looking for into a notepad file in the same TempLaunchFolder. But the odd thing is it actually places the text file in the SourceFolder. I figure this has something to do with how the memory works as the TempLaunchFolder is not always the same name if older ones never got deleted.

                          4. I used this code to read the text file and store the path info as my session path.
                          Code:
                          SessionVar.Set ("%store directory%", TextFileToString(_SourceFolder.. "\\text.txt"));
                          PLEASE READ AND HELP IF YOU CAN!!!
                          I am not sure after reading the string LEFT,Right or even MID details could loacte the string info i needed and extract. But if anyone knows how using the built in lua or sting variables i would like to know how. Basically look at the image i posted as that is what i needed without the double quotes around the path. The text to left would always be the same and could be used to locate the path.

















                          Comment


                          • #14
                            I started a new topic in discussion so consider this topic closed....

                            Comment


                            • #15
                              Ok thanks for telling us

                              Comment

                              Working...
                              X