• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS20 Auto-detect MSFS 2020 Community path

Messages
9
Country
switzerland
Hi there,

I'm currently building an auto-intaller for MSFS 2020 add-ons.

Currently, I know there is no registry key with the Community path as it was for FSX, so I must find another technique. Does any of you know a mechanism to get the current used Community path of MSFS 2020 ?

Thanks to all

Erik
 
However, after a check the folder C:\Users\*USERNAME*\AppData\Roaming\Microsoft Flight Simulator\ isn't present on my system. I will try to make a search for the file UserCfg.opt and let you know

Windows 10 with the latest update
MSFS2020 Windows Store version (downloaded)
 
Last edited:
Ok I found the file here C:\Users\*USERNAME*\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache

Would be nice to have all possible folders, so I could write a program to check each one, including STEAM
 
I can confirm Rikooooooooooos observation. This path:
%AppData%\Microsoft Flight Simulator\UserCfg.opt
doesn't exist for me.
%LOCALAPPDATA%\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg.opt
works.
Maybe it's dependent on the type of installation? Steam vs MS store vs Disc?
I'm running the sim from the MS store.
 
From memory the Steam path to the configs files is <USER>\AppData\Roaming\Microsoft Flight Simulator watch the spaces in Microsoft Flight Simulator

There have also been reported some different paths for users using a Game Pass. As for the disk edition I don't know do far but I would expect it to be the same as the version from MS Store
 
From Windows Explorer, set a search on your computer for the filename: UserCfg.opt
It may take a few minutes, but if the file exists at all, the path will be discovered... :wave:
 
Thanks n4gix, thanks to all.

But, because I have only one version of MSFS2020 I need to know the possible paths for others versions as I'm building an auto-installer for my customers.
So far, and correct me if I'm wrong, here is what I have collected:

-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
-MSFS 2020 DVD version:
????

Also, where to look if UserCfg.opt does not exist ? Some users reported that issue, but I think the file UserCfg.opt is created after the first run of MSFS2020.
And what if InstalledPackagesPath is not set ? So many questions...
 
Last edited:
I have a non default steam location installation, and there are two locations with two separate community folders.. the one that actually works is NOT in appdata area. The next small issue is the contents.xml file is also duplicated, but only one works, and that is NOT in the area of community folder that works.
The reason I had to find these was some packages would not appear in game unless they were specified in contents.xml. Others do appear in game and aren't specified in contents.xml.
All rather strange and may well cause your work to fail in some instances.
 
Is there any further info on this? I am also wanting to create installers for my content and having trouble figuring out how to utilize the great info in this thread.
 
For those that want use the great NSIS i did a nice example how to find either MS Store or STEAM Community folder.
Code:
;--------------------------------
!include "XPUI.nsh"
!include "LogicLib.nsh"
!include "x64.nsh"
!include "FileFunc.nsh"
/*
${FindIt} "C:\look_in_here" "find_this.txt" "$R0"
; At this point; $R0 is path to "find_this.txt" or -1 (not found)
*/
;--------------------------------
!macro FindIt In For Result
Push "${In}"
Push "${For}"
 Call FindIt
Pop "${Result}"
!macroend
!define FindIt "!insertmacro FindIt"

Function FindIt
Exch $R0
Exch
Exch $R1
Push $R2
Push $R3
Push $R4
Push $R5
Push $R6

 StrCpy $R6 -1
 StrCpy $R3 1

 Push $R1

 nextDir:
  Pop $R1
  IntOp $R3 $R3 - 1
  ClearErrors
   FindFirst $R5 $R2 "$R1\*.*"

 nextFile:
  StrCmp $R2 "." gotoNextFile
  StrCmp $R2 ".." gotoNextFile

  StrCmp $R2 $R0 0 isDir
   StrCpy $R6 "$R1\$R2"
   loop:
    StrCmp $R3 0 done
     Pop $R1
     IntOp $R3 $R3 - 1
     Goto loop

 isDir:

  IfFileExists "$R1\$R2\*.*" 0 gotoNextFile
  IntOp $R3 $R3 + 1
  Push "$R1\$R2"

 gotoNextFile:
  FindNext $R5 $R2
  IfErrors 0 nextFile

 done:
  FindClose $R5
  StrCmp $R3 0 0 nextDir
  StrCpy $R0 $R6

Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
;--------------------------------------
Function "GetMyAppData"
Var /GLOBAL AppDataFolder
  ReadRegStr $3 HKCU \
             "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\" \
             AppData
             StrCpy $AppDataFolder "$3"
FunctionEnd

 ;name and file
Name "SSW FIAT-AERITALIA G91"
OutFile "simskunkworks-aircraft-g91-1.0.0.exe"

;--------------------------------
;Interface Configuration
!define GRAPHICAL_INSTALLER_SPLASH_BITMAP "splash.bmp"
!define XPUI_HEADERIMAGE "${XPUI_SYSDIR}\Skins\Default\Header.bmp"
; might as well do a bottom image as well...
!define XPUI_BOTTOMIMAGE "${XPUI_SYSDIR}\Skins\Default\Botton.bmp" ;we don't have to define a custom bottom image, the default is fine.
!define XPUI_ABORTWARNING
!define XPUI_ENABLEBG
;--------------------------------
;Pages

  !insertmacro XPUI_PAGE_LICENSE ".\g91-eula.rtf"
  !insertmacro XPUI_PAGE_COMPONENTS
  !insertmacro XPUI_PAGE_DIRECTORY
  !insertmacro XPUI_PAGE_INSTFILES

  !insertmacro XPUI_PAGEMODE_UNINST
  !insertmacro XPUI_PAGE_UNINSTCONFIRM_NSIS
  !insertmacro XPUI_PAGE_INSTFILES

;==============================================
Section "!SSW FIAT G-91" SecSolo
  SetOutPath "$INSTDIR\simskunkworks-aircraft-g91\"
  File /r .\simskunkworks-aircraft-g91\*
SectionEnd
;===============================================
;Languages
!insertmacro XPUI_LANGUAGE "English"
;Descriptions
;Language strings
 LangString DESC_SecSolo ${LANG_ENGLISH} "Install SSW FIAT G-91 core files and liveries"
 ;Assign language strings to sections
 !insertmacro XPUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro XPUI_DESCRIPTION_TEXT ${SecSolo} $(DESC_SecSolo)
 !insertmacro XPUI_FUNCTION_DESCRIPTION_END
;==============================================
Function .onInit
 InitPluginsDir
  ; splash image
    File /oname=$PLUGINSDIR\splash.bmp ".\splash.bmp"
    File /oname=$PLUGINSDIR\g91_install.ini ".\g91_install.ini"
    splash::show 15000 $PLUGINSDIR\splash
    Pop $0 ; $0 has '1' if the user closed the splash screen early,
    ; '0' if everything closed normally, and '-1' if some error occurred.
;===============================================
; try to find either MS or STEAM install folder
;===============================================
    Var /GLOBAL MSStore
    Var /GLOBAL SteamStore
    StrCpy $MSStore "$LOCALAPPDATA\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages"
    ${FindIt} $MSSTORE "Community" $R0
    ${If} $R0 == "-1"
               goto notFoundStore
        ${Else}
               Strcpy $MSSTORE $R0
               goto foundSTore
        ${EndIf}
foundStore:
MessageBox MB_YESNO "Folder of Microsoft Flight Simulator (MS STORE) FOUND at:$\n\
$R0$\n Do you accept to install there ?" /SD IDYES IDNO answerNoMS
           StrCpy $INSTDIR $R0
           goto end
answerNoMS:
           goto notFoundSteam
notFoundStore:
           StrCpy $SteamStore "$LOCALAPPDATA\Packages\Microsoft.FlightDashboard_8wekyb3d8bbwe\LocalCache\Packages\"
           ${FindIt} $SteamStore "Community" $R0
           ${If} $R0 == "-1"
               goto notFoundSteam
           ${Else}
               goto foundSteam
           ${EndIf}
foundSteam:
MessageBox MB_YESNO "Folder of Microsoft Flight Simulator (STEAM edition) FOUND at:$\n\
$R0$\n Do you accept to install there ?" /SD IDYES IDNO notFoundSteam
           StrCpy $INSTDIR $R0
           goto end
notFoundSteam:
MessageBox MB_OK "Installation folder not detected or not accepted,$\n please point the installer to your Community Folder"
;
;
end:
;MessageBox MB_OK "Install dir at:$INSTDIR"
FunctionEnd
 
For those interested I've made a VBScript that looks into UserCfg.opt and extract the community path

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
 
For those interested I've made a VBScript that looks into UserCfg.opt and extract the community path

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

I am trying to get setup factory installer to run the vbscript. If i just run it by double clicking i get an error "The handle is invalid". 800070006.
Any help would be great.

My plan is to use the LUA script to run the VBScript using ReturnCode = FileRun as this will store the variable in ReturnCode.
 
For those interested I've made a VBScript that looks into UserCfg.opt and extract the community path

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
I rewrote your script so any installer can run this script from any location and it will look for the Windows store version of the msfs2020 UserCFG.opt file and then output the path into a new text file called directory.txt in the same location the script was executed from. This way that installer can now simply read the new text file for the path to install. At least my installer program needs to use this method and also needs to run the script from a temp folder. Hope this help someone.
Code:
'-----------------------------------------------------------------
'This script used to read the UserCfg.opt filename
'Match "InstalledPackagesPath" string and extract the path value
'-----------------------------------------------------------------

'Variable declaration
filename = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%USERPROFILE%") & "\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\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
 
I rewrote your script so any installer can run this script from any location and it will look for the Windows store version of the msfs2020 UserCFG.opt file and then output the path into a new text file called directory.txt in the same location the script was executed from. This way that installer can now simply read the new text file for the path to install. At least my installer program needs to use this method and also needs to run the script from a temp folder. Hope this help someone.
Code:
'-----------------------------------------------------------------
'This script used to read the UserCfg.opt filename
'Match "InstalledPackagesPath" string and extract the path value
'-----------------------------------------------------------------

'Variable declaration
filename = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%USERPROFILE%") & "\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\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
Excellent idea, some way to use it in Inno Setup ?? some code please
 
Excellent idea, some way to use it in Inno Setup ?? some code please
Try this out, in your CODE section:

Code:
var SteamOPT, StoreOPT: string;
var OPT_Contents: AnsiString;
var SteamExists, StoreExists: Boolean;
var InstalledPackagesPos: Integer;
var TrimTrail: LongInt;
function DetectMSFS(Param: String): String;
  begin
    SteamOPT := ExpandConstant('{userappdata}') + '\Microsoft Flight Simulator\UserCfg.opt';
    StoreOPT := ExpandConstant('{localappdata}') + '\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg.opt';
    SteamExists := FileExists(SteamOPT);
    StoreExists := FileExists(StoreOPT);
    if (SteamExists) then
      LoadStringFromFile(SteamOPT, OPT_Contents)
    else if (StoreExists) then
      LoadStringFromFile(StoreOPT, OPT_Contents)
    else
      OPT_Contents := 'C:\';
    if not (OPT_Contents = 'C:\') then
      InstalledPackagesPos := Pos('InstalledPackagesPath', OPT_Contents)+ 22;
      Delete(OPT_Contents, 1, InstalledPackagesPos);
      TrimTrail := Length(OPT_Contents) - 1;
      Delete(OPT_Contents, TrimTrail, 5);
      OPT_Contents := OPT_Contents + '\mnd-aircraft-c22j\';
    Result := OPT_Contents
  end;

Usage:
Code:
DefaultDirName={code:DetectMSFS}

May have serious bugs hidden here and there!
 
Back
Top