how to terminate installer if unstallation of legacy version of software is cancelled before executing it? - return-value

I have created an installer(myinstaller) using innosetup to install an application (myapp).
The code snippet is :
function legacy_check(): Boolean;
begin
ShellExec('runas', 'rundll32.exe', 'dfshim.dll,ShArpMaintain SecretsUtility.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=amd64', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
Result := True;
end;
function InitializeSetup(): Boolean;
begin
Result:=legacy_check(); // after this line only inno setup wizard page will appear
// code to install latest version
end;
Here the function legacy_check() checks for existance of old version of myapp in the system and uninstalls it and returns true . so that myinstaller can proceed further .
But, here during uninstallation of old version , it asks user whether to uninstall or not. That time if user presses OK to uninstall, it works fine .But if user presses cancel to uninstall old version ,it should terminate myinstaller.But it is not terminating Since it returns True anyway.
So i think i need to get some return code when user presses cancel button to uninstall ,so that using return code i can return either true or false .
So Is there any way to get returncode when user presses cancel to uninstall , so that i can use it after the line,
ShellExec('runas', 'rundll32.exe', 'dfshim.dll,ShArpMaintain SecretsUtility.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=amd64', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode); ?
otherwise please tell me how to uninstall it silently . I am confused about how to use /SILENT parameter in ShellExec since there are parameters present already .
So please suggest me some idea.

I changed my code as below to achieve the requirement :
function legacy_check(): Boolean;
begin
ShellExec('runas', 'rundll32.exe', 'dfshim.dll,ShArpMaintain SecretsUtility.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=amd64', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
if RegKeyExists(HKEY_CURRENT_USER,'Software\Microsoft\Windows\CurrentVersion\Uninstall\myapp') then
Result := False
else
Result := True;
end;
function InitializeSetup(): Boolean;
begin
Result:=legacy_check();
if Not Result then
begin
Result:=False
else
// code to install latest version
end;

Related

How to reload a postgres C extension?

I've created a C extension defining the shell of a function that I can call from SQL code in Postgresql 12.3. I'm using PGXS to build and install the extension. I can build, install and call the function, but if I make changes and reinstall, the changes don't show.
The make file is:
MODULES = bar
EXTENSION = bar
DATA = bar--0.0.1.sql
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
bar.control is
comment = 'Simple bar function'
default_version = '0.0.1'
relocatable = true
module_pathname = '$libdir/bar'
bar--0.0.1.sql is:
CREATE OR REPLACE FUNCTION
bar(jsonb) RETURNS int AS 'MODULE_PATHNAME','bar'
LANGUAGE C STRICT;
bar.c is:
#include "postgres.h"
#include "fmgr.h"
PG_MODULE_MAGIC;
PG_FUNCTION_INFO_V1(bar);
Datum bar(PG_FUNCTION_ARGS)
{
PG_RETURN_INT32(101);
}
I run make install to do the install. And then
drop extension bar; create extension bar; but the changes won't show when I call the function. The only way I can install a new version is to restart postgres. What step am I missing?
Well, I discovered that if I just create a new connection to the DB the changes will show. That isn't so bad, I suppose. Does that have to do with how postgres uses fork() to create a new process for each connection?
When you execute your function, the shared library gets loaded into your backend process and stays there. Replacing the shared library on disk does not modify the in-memory copy loaded into your process. You have to start a new database connection and execute the function again to get the new version.

how to open new instance of acrobat

I'm using windows 10 task view and need to open different instances of excel word and acrobat.
I can't seem to get acrobat working. I get error: 0x800401F3 - Invalid class string on the AcroApp := ComObjCreate("AcroExch.App") line.
Any suggestions?
^+n::
oWord := ComObjCreate("Word.Application")
oWord.Documents.Add
oWord.Visible := 1
oWord.Activate
xlApp := ComObjCreate("Excel.Application")
xlApp.Visible := true
xlApp.Workbooks.Add()
xlApp := ""
run notepad
run chrome
AcroApp := ComObjCreate("AcroExch.App"); Error when running
AcroApp.Visible := true
AcroApp.Open
return
While the COM approach seems cool, it seems really unnecessary.
I don't have Acrobat, but a quick Google search tells me they have a command line option to open a new instance, as I suspected (documented here).
So, a quick little run command should do the trick:
Run, % """C:\Path\To\Acrobat.exe"" /n"
Also, maybe this is why your COM approach didn't work?

Find the path of an application, and copy a file to that directory in Inno Setup

I'd like to install a file into a user's MATLAB folder in Inno Setup. But depending on the version of MATLAB, the directory can change.
In the Windows command line, it is possible to get the path of the MATLAB executable like so:
where matlab
Which will output
C:\Program Files (x86)\MATLAB\R2015b\bin\matlab.exe
I'd like to copy a file in the following folder
C:\Program Files (x86)\MATLAB\R2015b\toolbox\local
How can this be done?
The where command searches the file in the path specified by the PATH environment variable.
In Inno Setup Pascal Script, you can implement that using FileSearch function, like:
FileSearch('matlab.exe', GetEnv('PATH'))
Though I'd say, that there's must be a better way to find installation folder of MATLAB.
Anyway, you can resolve the path using the above method to a global variable in InitializeSetup event function. It will also allow you to abort the installation, when MATLAB is not found.
And then you can use the variable as an installation path using a scripted constant.
[Files]
Source: "MyFile.dat"; DestDir: "{code:GetMatlabToolboxLocalPath}"
[Code]
var
MatlabToolboxLocalPath: string;
function GetMatlabToolboxLocalPath(Param: string): string;
begin
Result := MatlabToolboxLocalPath;
end;
function InitializeSetup(): Boolean;
var
MatlabExePath: string;
begin
MatlabExePath := FileSearch('matlab.exe', GetEnv('PATH'));
if MatlabExePath = '' then
begin
MsgBox('Cannot find MATLAB', mbError, MB_OK);
Result := False;
Exit;
end;
MatlabToolboxLocalPath := ExtractFilePath(MatlabExePath) + '..\toolbox\local';
Result := True;
end;

interrupted system call and socket operation on non-socket Errors, Delphi

I use TidHttp component to upload too many files to the server , but while the application uploading the files this error's raised to me !
socket error #10004 interrupted system call and
socket error #10038 socket operation on non-socket .
Honestly, I don't know what this errors mean !!
this is my code to upload the files !
procedure TForm1.Button1Click(Sender: TObject);
var
StreamFiles: TIdMultiPartFormDataStream;
path : string;
begin
StreamFiles := TIdMultiPartFormDataStream.Create;
path := 'D:\example.doc' ;
try
StreamFiles.AddFile('upload_file', path, 'text/plain');
try
IdHTTP1.Post('http://myserver.com/upload/files', StreamFiles);
except
on E: Exception do
ShowMessage('Error encountered during POST: ' + E.Message);
end;
finally
StreamFiles.Free;
end;
end;

innosetup, uninstall shared service

I am installing and uninstalling some service apps via InnoSetup's code section as below.
ShellExec('', ExpandConstant('{app}\') + dExeName, '/install /silent', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
....
ShellExec('', ExpandConstant('{app}\') + dExeName, '/uninstall /silent', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
Now I have a seperate application which using the same service. both applications' installer installs and uninstalls those services.
I need a solution that the uninstaller should not uninstall if other application still exists on the computer.
Faruk.
Best regards.
Both installers should set an entry in the Registry using the [Registry] Section (http://www.jrsoftware.org/ishelp/index.php?topic=registrysection) setting the flag uninsdeletekey.
In both uninstallers you can check then whether the other application is still installed by doing something like
if not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Faruk\OtherSoftwareName') then
begin
// The key exists
ShellExec('', ExpandConstant('{app}\') + dExeName, '/uninstall /silent', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
end;