Installer: Add "Add to Explorer's Context Menu" option.

This commit is contained in:
Nodir Temirkhodjaev 2021-03-24 17:05:30 +03:00
parent 82bb84aff3
commit b56f0b75b7
2 changed files with 39 additions and 8 deletions

View File

@ -6,6 +6,8 @@
#define APP_EXE_NAME "FortFirewall.exe" #define APP_EXE_NAME "FortFirewall.exe"
#define APP_ICO_NAME "FortFirewall.ico" #define APP_ICO_NAME "FortFirewall.ico"
#define APP_EXE StringChange("{app}\%exe%", "%exe%", APP_EXE_NAME)
[Setup] [Setup]
; NOTE: The value of AppId uniquely identifies this application. ; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications. ; Do not use the same AppId value in installers for other applications.
@ -40,19 +42,32 @@ Name: ru; MessagesFile: "compiler:Languages\Russian.isl"
[Tasks] [Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; Flags: unchecked Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; Flags: unchecked
Name: "explorer"; Description: "Add to Explorer's Context Menu"; Flags: unchecked
Name: "portable"; Description: "Portable"; Flags: unchecked Name: "portable"; Description: "Portable"; Flags: unchecked
[Files] [Files]
Source: "build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "README.portable"; DestDir: "{app}"; Check: IsTaskSelected('portable') Source: "README.portable"; DestDir: "{app}"; Check: IsTaskSelected('portable')
[Registry]
; Explorer's Context Menu
#define REG_SHELL_MENU "SystemFileAssociations\.exe\Shell\Fort Firewall"
Root: HKCR; Subkey: "{#REG_SHELL_MENU}"; Flags: deletekey uninsdeletekey
Root: HKCR; Subkey: "{#REG_SHELL_MENU}"; ValueType: string; ValueName: "icon"; ValueData: "{#APP_EXE}"; \
Check: IsTaskSelected('explorer')
Root: HKCR; Subkey: "{#REG_SHELL_MENU}"; ValueType: string; ValueName: "MUIVerb"; ValueData: "Fort Firewall ..."; \
Check: IsTaskSelected('explorer')
Root: HKCR; Subkey: "{#REG_SHELL_MENU}\command"; ValueType: string; ValueData: """{#APP_EXE}"" -c prog add ""%1"""; \
Check: IsTaskSelected('explorer')
[Icons] [Icons]
; Start menu shortcut ; Start menu shortcut
Name: "{group}\{#APP_NAME}"; Filename: "{app}\{#APP_EXE_NAME}"; WorkingDir: "{app}"; Parameters: "--lang {code:LanguageName}" Name: "{group}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}"; Parameters: "--lang {code:LanguageName}"
; Uninstaller shortcut ; Uninstaller shortcut
Name: "{group}\{cm:UninstallProgram,{#APP_NAME}}"; Filename: "{uninstallexe}" Name: "{group}\{cm:UninstallProgram,{#APP_NAME}}"; Filename: "{uninstallexe}"
; Desktop shortcut ; Desktop shortcut
Name: "{commondesktop}\{#APP_NAME}"; Filename: "{app}\{#APP_EXE_NAME}"; WorkingDir: "{app}"; Parameters: "--lang {code:LanguageName}"; Tasks: desktopicon Name: "{commondesktop}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}"; \
Parameters: "--lang {code:LanguageName}"; Tasks: desktopicon
[Run] [Run]
Filename: "{app}\driver\scripts\reinstall.bat"; Description: "Re-install driver"; Flags: runascurrentuser Filename: "{app}\driver\scripts\reinstall.bat"; Description: "Re-install driver"; Flags: runascurrentuser
@ -61,7 +76,7 @@ Filename: "https://support.microsoft.com/en-us/help/2977003/the-latest-supported
[UninstallRun] [UninstallRun]
Filename: "{app}\driver\scripts\uninstall.bat"; RunOnceId: "DelDriver"; Flags: runascurrentuser Filename: "{app}\driver\scripts\uninstall.bat"; RunOnceId: "DelDriver"; Flags: runascurrentuser
Filename: "{app}\{#APP_EXE_NAME}"; Parameters: "-b=0"; RunOnceId: "DelProvider"; Flags: runascurrentuser Filename: "{#APP_EXE}"; Parameters: "-b=0"; RunOnceId: "DelProvider"; Flags: runascurrentuser
[InstallDelete] [InstallDelete]
Type: filesandordirs; Name: "{app}" Type: filesandordirs; Name: "{app}"

View File

@ -75,8 +75,8 @@ bool ControlManager::processCommand(
{ {
const int argsSize = args.size(); const int argsSize = args.size();
if (command == QLatin1String("ini")) { if (command == "ini") {
if (argsSize < 3) { if (argsSize < 2) {
errorMessage = "ini <property> <value>"; errorMessage = "ini <property> <value>";
return false; return false;
} }
@ -84,8 +84,8 @@ bool ControlManager::processCommand(
auto settings = m_fortManager->settings(); auto settings = m_fortManager->settings();
settings->setProperty(args.at(0).toLatin1(), QVariant(args.at(1))); settings->setProperty(args.at(0).toLatin1(), QVariant(args.at(1)));
} else if (command == QLatin1String("conf")) { } else if (command == "conf") {
if (argsSize < 3) { if (argsSize < 2) {
errorMessage = "conf <property> <value>"; errorMessage = "conf <property> <value>";
return false; return false;
} }
@ -94,7 +94,7 @@ bool ControlManager::processCommand(
const auto confPropName = args.at(0); const auto confPropName = args.at(0);
if (confPropName == QLatin1String("appGroup")) { if (confPropName == "appGroup") {
if (argsSize < 4) { if (argsSize < 4) {
errorMessage = "conf appGroup <group-name> <property> <value>"; errorMessage = "conf appGroup <group-name> <property> <value>";
return false; return false;
@ -107,6 +107,22 @@ bool ControlManager::processCommand(
} }
m_fortManager->saveOriginConf(tr("Control command executed")); m_fortManager->saveOriginConf(tr("Control command executed"));
} else if (command == "prog") {
if (argsSize < 1) {
errorMessage = "prog <command>";
return false;
}
const auto progCommand = args.at(0);
if (progCommand == "add") {
if (argsSize < 2) {
errorMessage = "prog add <app-path>";
return false;
}
m_fortManager->showProgramEditForm(args.at(1));
}
} }
return true; return true;