Author Topic: A question on (un)installers...  (Read 986 times)

clamicun

  • Member
  • ***
  • Posts: 250
A question on (un)installers...
« on: August 08, 2015, 12:05:05 AM »
I am writing my own (un)install "Install_ProgName.exe".
So far the installer is without any problem.

The "Uninstaller" (Uninstall_ProgName.exe) is.

It seems to be state of the art that the executing file and the uninstall file are in the same folder.

Uninstall  deletes all files in the folder e.g. C:\Program Files\ProgName\. -ok.

But how do I "convince" the uninstaller to finally kill itself and the folder it is in.
Someone could give me a hint ?

jj2007

  • Member
  • *****
  • Posts: 7765
  • Assembler is fun ;-)
    • MasmBasic
Re: A question on (un)installers...
« Reply #1 on: August 08, 2015, 12:26:35 AM »
Copy the uninstaller to C:\temp, then launch it from there.

Windows doesn't particularly like what you want to do, that's why they made it difficult...

clamicun

  • Member
  • ***
  • Posts: 250
Re: A question on (un)installers...
« Reply #2 on: August 08, 2015, 12:35:45 AM »
Hi JJ,
Do you mean, the INSTALL copies the UNINSTALL to a different folder?
I was thinking on that, because it is no deal to delete the installfolder from outside.

But - as i said - ... all installed software on my computer has the 2 files in the same folder.   

jj2007

  • Member
  • *****
  • Posts: 7765
  • Assembler is fun ;-)
    • MasmBasic
Re: A question on (un)installers...
« Reply #3 on: August 08, 2015, 01:13:27 AM »
The only real problem is that the uninstaller itself is locked when you use it, so you can't delete it, and subsequently the whole folder cannot be deleted. That is why you must launch it from outside. Example with some error checking:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  SetGlobals Src$, Dest$, Kill$
  Init
  .if Instr_(CL$(), "@")
      inc eax
      Let Kill$=eax
      MsgBox 0, Kill$, "Kill that file?", MB_OKCANCEL
      .if eax==IDOK
            invoke SetLastError, 0
            Kill Kill$
            deb 4, "Killed", $Kill$, $Err$()
      .endif
  .else
      Let Src$=CL$(0)      ; arg 0 is the exe itself
      .if Rinstr(Src$, "\")
            xchg eax, ecx
            Let Dest$=Cat$(ExpandEnv$("%TMP%")+ecx)
            PrintLine "Src:", Tb$, Src$
            PrintLine "Dest:", Tb$, Dest$
            invoke CopyFile, Src$, Dest$, 0
            deb 4, "CopyFile", eax, $Err$()
            Launch Cat$(Dest$+" @"+Src$), SW_RESTORE, 1
            PrintLine "Bye"
      .endif
  .endif
  Exit
end start

clamicun

  • Member
  • ***
  • Posts: 250
Re: A question on (un)installers...
« Reply #4 on: August 11, 2015, 12:06:50 AM »
JJ,
yes - nicely done. Kills the uninstallfile.  But...

It works from outside - that is, it does not kill itself, but the copy kills the original file.
And this copy stays in the tmpFolder.

I am debugging professional uninstallers.
May be I'll find out, how they do it.

jj2007

  • Member
  • *****
  • Posts: 7765
  • Assembler is fun ;-)
    • MasmBasic
Re: A question on (un)installers...
« Reply #5 on: August 11, 2015, 01:02:35 AM »
And this copy stays in the tmpFolder.

Right. This is normally not a problem, if users delete their tmp stuff regularly.

You may test this:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Print CL$(0)
  invoke SetLastError, 0
  invoke MoveFileEx, CL$(0), 0, MOVEFILE_DELAY_UNTIL_REBOOT
  deb 4, "MFX", eax, $Err$()
  Exit
end start


CL$(0) is the current executable. Reboot and check if it's still there...

clamicun

  • Member
  • ***
  • Posts: 250
Re: A question on (un)installers...
« Reply #6 on: August 11, 2015, 06:48:18 PM »
JJ,
ofcourse it works - as everything you write.

"This is normally not a problem, if users delete their tmp stuff regularly."

That's no problem for you and me.
But you know that 90% of all WindowsUsers on this planet do not have the slightest idea, what they are doing.