Reputation: 1
I'm building a program in python that needs to create and modify a config.json file. It all works well until i build it, make it an installation .exe file using innosetup, and then installing it in the program folder. now, i not that to manage files and folders in that path u need to have special permissions but i don't know how to grant them using innosetup. The following is my innosetup file:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "2.0"
#define MyAppPublisher "Me"
#define MyAppExeName "main.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{8CC8270A-A721-4074-8F3B-61E1AABBFCD9}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={autopf}\{#MyAppName}
ChangesAssociations=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "D:\Programmazione\ytDownloader\output\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Program Files\ffmpeg\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
I create and manage the file directly in my main python code in the way that it is created directly in the path where the main file is, so if it is in the "Program Files" folder it creates into that. That's why i have to understand how to manage permissions in innosetup. The following is how:
class App():
def __init__(self):
super().__init__()
self.cfgFile = "config.json"
self.cfg = self.load_cfg()
def load_cfg(self) -> dict:
data = {}
if os.path.exists(self.cfgFile):
with open(self.cfgFile, "r") as f:
data = json.load(f)
if len(data) < 7:
data = {
"audio_path": os.getcwd(),
"video_path": os.getcwd(),
"threads": "20",
"formato_audio": "mp3",
"formato_video": "mp4",
"tipo": "audio",
"last_link": ""
}
data = {
"my_data": "",
}
self.save_cfg(data)
return data
def save_cfg(self, data = None) -> None:
data = self.cfg if data == None else data
with open(self.cfgFile, "w") as f:
json.dump(data, f, indent=4)
I tried reading the documentation of innosetup but i'm not such an expert and i didn't find anything useful, only some rows that wasn't much selfexplainatory and i don't want to risk to mess everything up
Upvotes: 0
Views: 27