{"id":1750,"date":"2024-09-18T13:36:54","date_gmt":"2024-09-18T16:36:54","guid":{"rendered":"https:\/\/blog.abratel.com.br\/?p=1750"},"modified":"2024-12-27T21:22:10","modified_gmt":"2024-12-28T00:22:10","slug":"how-to-create-a-openvpn-installer-with-all-certificates-and-setting-already-built-in","status":"publish","type":"post","link":"https:\/\/blog.abratel.com.br\/?p=1750","title":{"rendered":"How to create a openvpn installer with all certificates and setting already built in"},"content":{"rendered":"<p>1 &#8211; Download and install Inno Setup: https:\/\/jrsoftware.org\/isinfo.php<\/p>\n<p>2 &#8211; Create a Folder on your PC for the input and output dates:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nCreate this folder: C:\\MyOpenVPNInstaller\\Input\n\n\u251c\u2500\u2500 openvpn.msi (OpenVPN executable - download the version needed and place here withi this name)\n\u251c\u2500\u2500 config\n\u2502   \u2514\u2500\u2500 myvpn.ovpn\n\u251c\u2500\u2500 certs (Optional - if needed for certificates)\n\u2514\u2500\u2500 other files (Optional - if needed for certificates)\n\ncreate this folder: C:\\MyOpenVPNInstaller\\Output\n<\/pre>\n<p>3 &#8211; Colar o script no Inno Setup<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n; Script generated by the Inno Setup Script Wizard.\n; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!\n\n#define MyAppName &quot;OpenVPN&quot;\n#define MyAppVersion &quot;2.0&quot;\n#define MyAppPublisher &quot;Company&quot;\n#define MyAppURL &quot;https:\/\/www.company.com.br\/&quot;\n#define MyAppExeName &quot;company.exe&quot;\n#define MyAppAssocName MyAppName + &quot; File&quot;\n\n[Setup]\n; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.\n; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)\nAppId={{5F717633-6F6B-4164-8A77-023E862DED16}\nAppName={#MyAppName}\nAppVersion={#MyAppVersion}\n;AppVerName={#MyAppName} {#MyAppVersion}\nAppPublisher={#MyAppPublisher}\nAppPublisherURL={#MyAppURL}\nAppSupportURL={#MyAppURL}\nAppUpdatesURL={#MyAppURL}\nDefaultDirName={autopf}\\{#MyAppName}\nDisableDirPage=yes\n; &quot;ArchitecturesAllowed=x64compatible&quot; specifies that Setup cannot run\n; on anything but x64 and Windows 11 on Arm.\nArchitecturesAllowed=x64compatible\n; &quot;ArchitecturesInstallIn64BitMode=x64compatible&quot; requests that the\n; install be done in &quot;64-bit mode&quot; on x64 or Windows 11 on Arm,\n; meaning it should use the native 64-bit Program Files directory and\n; the 64-bit view of the registry.\nArchitecturesInstallIn64BitMode=x64compatible\nChangesAssociations=yes\nDisableProgramGroupPage=yes\n; Uncomment the following line to run in non administrative install mode (install for current user only.)\n;PrivilegesRequired=lowest\nOutputDir=C:\\MyOpenVPNInstaller\\Output\nOutputBaseFilename=OpenVPNInstaller\nCompression=lzma\nSolidCompression=yes\nWizardStyle=modern\nUninstallable=yes\nPrivilegesRequired=admin\nAllowNoIcons=yes\n\n[Languages]\nName: &quot;english&quot;; MessagesFile: &quot;compiler:Default.isl&quot;\n\n[Tasks]\nName: &quot;desktopicon&quot;; Description: &quot;{cm:CreateDesktopIcon}&quot;; GroupDescription: &quot;{cm:AdditionalIcons}&quot;; Flags: unchecked\n\n[Files]\n; Include the OpenVPN MSI installer\nSource: &quot;C:\\MyOpenVPNInstaller\\Input\\openvpn.msi&quot;; DestDir: &quot;{tmp}&quot;; Flags: deleteafterinstall\n; Include your custom .ovpn file\nSource: &quot;C:\\MyOpenVPNInstaller\\Input\\config\\*&quot;; DestDir: &quot;{app}\\config&quot;; Flags: ignoreversion\n\n[Run]\n; Run the OpenVPN MSI installer in 64-bit mode\nFilename: &quot;msiexec.exe&quot;; Parameters: &quot;\/i {tmp}\\openvpn.msi \/quiet&quot;; WorkingDir: &quot;{tmp}&quot;; Flags: waituntilterminated\n\n[Icons]\n; Create shortcuts to OpenVPN GUI (without specifying run-as-admin flag here)\nName: &quot;{group}\\OpenVPN GUI&quot;; Filename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; WorkingDir: &quot;{pf}\\OpenVPN\\bin&quot;; IconFilename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; IconIndex: 0\nName: &quot;{commondesktop}\\OpenVPN GUI&quot;; Filename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; WorkingDir: &quot;{pf}\\OpenVPN\\bin&quot;; IconFilename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; IconIndex: 0\n\n[UninstallDelete]\n; Remove the custom .ovpn file and other custom files during uninstall\nType: files; Name: &quot;{app}\\config&quot;\n\n[UninstallRun]\n; Uninstall OpenVPN using the MSI uninstaller\nFilename: &quot;msiexec.exe&quot;; Parameters: &quot;\/x {tmp}\\openvpn.msi \/quiet&quot;; Flags: waituntilterminated\n\n[Code]\nprocedure CurStepChanged(CurStep: TSetupStep);\nbegin\nif CurStep = ssPostInstall then\nbegin\n\/\/ This is where you might need to add custom logic to modify shortcut properties.\n\/\/ For example, you could use a tool like 'NirCmd' or similar to modify the shortcut.\n\/\/ Unfortunately, Inno Setup does not have built-in support for setting run-as-admin properties directly.\nend;\nend;\n<\/pre>\n<p>4 &#8211; Compitale with CTRL + F9 and check for errors.<\/p>\n<p>5 &#8211; Install the installer created: C:\\MyOpenVPNInstaller\\Output\\OpenVPNInstaller.exe<\/p>\n<p>==================================================================<\/p>\n<p>Updated Script<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n; Script generated by the Inno Setup Script Wizard.\n; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!\n\n#define MyAppName &quot;OpenVPN&quot;\n#define MyAppVersion &quot;2.0&quot;\n#define MyAppPublisher &quot;ESB&quot;\n#define MyAppURL &quot;&quot;\n#define MyAppExeName &quot;ESB Office VPN.exe&quot;\n#define MyAppAssocName MyAppName + &quot; File&quot;\n\n[Setup]\n; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.\n; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)\nAppId={{5F717633-6F6B-4164-8A77-023E862DED16}\nAppName={#MyAppName}\nAppVersion={#MyAppVersion}\n;AppVerName={#MyAppName} {#MyAppVersion}\nAppPublisher={#MyAppPublisher}\nAppPublisherURL={#MyAppURL}\nAppSupportURL={#MyAppURL}\nAppUpdatesURL={#MyAppURL}\nDefaultDirName={autopf}\\{#MyAppName}\nDisableDirPage=yes\n; &quot;ArchitecturesAllowed=x64compatible&quot; specifies that Setup cannot run\n; on anything but x64 and Windows 11 on Arm.\nArchitecturesAllowed=x64compatible\n; &quot;ArchitecturesInstallIn64BitMode=x64compatible&quot; requests that the\n; install be done in &quot;64-bit mode&quot; on x64 or Windows 11 on Arm,\n; meaning it should use the native 64-bit Program Files directory and\n; the 64-bit view of the registry.\nArchitecturesInstallIn64BitMode=x64compatible\nChangesAssociations=yes\nDisableProgramGroupPage=yes\n; Uncomment the following line to run in non administrative install mode (install for current user only.)\n;PrivilegesRequired=lowest\nOutputDir=C:\\Users\\Owner\\Desktop\\sedim\\Output\nOutputBaseFilename=OpenVPNInstaller-ESB\nCompression=lzma\nSolidCompression=yes\nWizardStyle=modern\nUninstallable=yes\nPrivilegesRequired=admin\nAllowNoIcons=yes\n\n[Languages]\nName: &quot;english&quot;; MessagesFile: &quot;compiler:Default.isl&quot;\n\n[Tasks]\nName: &quot;desktopicon&quot;; Description: &quot;{cm:CreateDesktopIcon}&quot;; GroupDescription: &quot;{cm:AdditionalIcons}&quot;; Flags: unchecked\n\n[Files]\n; Include the OpenVPN MSI installer\nSource: &quot;C:\\Users\\Owner\\Desktop\\sedim\\Input\\openvpn.msi&quot;; DestDir: &quot;{tmp}&quot;; Flags: deleteafterinstall\n; Include your custom .ovpn file\nSource: &quot;C:\\Users\\Owner\\Desktop\\sedim\\Input\\config\\*&quot;; DestDir: &quot;{app}\\config&quot;; Flags: ignoreversion\n\n[Run]\n; Run the OpenVPN MSI installer in 64-bit mode\nFilename: &quot;msiexec.exe&quot;; Parameters: &quot;\/i {tmp}\\openvpn.msi \/quiet&quot;; WorkingDir: &quot;{tmp}&quot;; Flags: waituntilterminated\n\n[Icons]\n; Create shortcuts to OpenVPN GUI (without specifying run-as-admin flag here)\nName: &quot;{group}\\OpenVPN GUI&quot;; Filename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; WorkingDir: &quot;{pf}\\OpenVPN\\bin&quot;; IconFilename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; IconIndex: 0\nName: &quot;{commondesktop}\\OpenVPN GUI&quot;; Filename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; WorkingDir: &quot;{pf}\\OpenVPN\\bin&quot;; IconFilename: &quot;{pf}\\OpenVPN\\bin\\openvpn-gui.exe&quot;; IconIndex: 0\n\n[UninstallDelete]\n; Remove the custom .ovpn file and other custom files during uninstall\nType: files; Name: &quot;{app}\\config&quot;\n\n[UninstallRun]\n; Uninstall OpenVPN using the MSI uninstaller\nFilename: &quot;msiexec.exe&quot;; Parameters: &quot;\/x {tmp}\\openvpn.msi \/quiet&quot;; Flags: waituntilterminated\n\n[Code]\nprocedure CurStepChanged(CurStep: TSetupStep);\nbegin\nif CurStep = ssPostInstall then\nbegin\n\/\/ This is where you might need to add custom logic to modify shortcut properties.\n\/\/ For example, you could use a tool like 'NirCmd' or similar to modify the shortcut.\n\/\/ Unfortunately, Inno Setup does not have built-in support for setting run-as-admin properties directly.\nend;\nend;\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1 &#8211; Download and install Inno Setup: https:\/\/jrsoftware.org\/isinfo.php 2 &#8211; Create a Folder on your PC for the input and output dates: 3 &#8211; Colar o script no Inno Setup 4 &#8211; Compitale with CTRL + F9 and check for errors. 5 &#8211; Install the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1752,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1750"}],"collection":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1750"}],"version-history":[{"count":6,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1750\/revisions"}],"predecessor-version":[{"id":1767,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1750\/revisions\/1767"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/media\/1752"}],"wp:attachment":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}