Page 1 of 2
How to make Uninstaller?
Posted: Sun Nov 20, 2022 11:59 am
by GogaII
Hi everyone!
I was not able to find a good way to delete a folder with a program where the program is running (under Windows 10).
I don't want to use a program like the Inno Setup (because I wrote already my own Installer)
I used to use a script but now the Windows defender reports that this is a virus and this way doesn't work any more.
I found a solution here but it requires an Administration mode, that is unacceptable for me.
Could anyone advice me something?
Re: How to make Uninstaller?
Posted: Sun Nov 20, 2022 12:43 pm
by mk-soft
You should be able to tell Windows that it is not a virus. I don't know where to report this.
Avira has a special page for reporting this and it has always worked so far.
Maybe extend the programme with some unnecessary function (e.g. image). Sometimes it also helps that the programme no longer displays a virus message.
Re: How to make Uninstaller?
Posted: Sun Nov 20, 2022 5:34 pm
by Bitblazer
GogaII wrote: Sun Nov 20, 2022 11:59 am
Could anyone advice me something?
Check
NSIS and how they do it.
Re: How to make Uninstaller?
Posted: Sun Nov 20, 2022 11:57 pm
by idle
Did you try to copy your uninstaller.exe to GetTemporaryDirectory() and run it from there?
Re: How to make Uninstaller?
Posted: Mon Nov 21, 2022 10:42 am
by Marc56us
idle wrote: Sun Nov 20, 2022 11:57 pm
Did you try to copy your uninstaller.exe to GetTemporaryDirectory() and run it from there?
Yes, this is the right method, that's how the uninstaller works (since windows 3.x)
The program copies itself into %temp%, then terminates and starts its copy.
No security problem because the temporary directory is personal to each user (and to the admin) and is not on the network.
Re: How to make Uninstaller?
Posted: Mon Nov 21, 2022 2:48 pm
by Bitblazer
Marc56us wrote: Mon Nov 21, 2022 10:42 am
The program copies itself into %temp%, then terminates and starts its copy.
Last time i tried that, my windows AV blocked it and quarantined my exe - an exe that creates another exe and runs it, is a common trojan behaviour

Sadly that is no joke.
Re: How to make Uninstaller?
Posted: Mon Nov 21, 2022 3:06 pm
by Marc56us
Bitblazer wrote: Mon Nov 21, 2022 2:48 pm
Marc56us wrote: Mon Nov 21, 2022 10:42 am
The program copies itself into %temp%, then terminates and starts its copy.
Last time i tried that, my windows AV blocked it and quarantined my exe - an exe that creates another exe and runs it, is a common trojan behaviour

Sadly that is no joke.
Hi,
Yes, an EXE that creates an EXE is indeed seen as a virus, but an EXE that
Copy itself elsewhere (on same disk) should not be seen as a virus since the original is already present on the disk (so already scanned)
(Change AV)

Re: How to make Uninstaller?
Posted: Fri Nov 25, 2022 2:16 pm
by GogaII
idle wrote: Sun Nov 20, 2022 11:57 pm
Did you try to copy your uninstaller.exe to GetTemporaryDirectory() and run it from there?
This method doesn't work with me ((. The Windows defender shouts that this is a virus (
I'm going to communicate with MS. Probably, they will suggest any solution.
Re: How to make Uninstaller?
Posted: Fri Nov 25, 2022 2:21 pm
by GogaII
Bitblazer wrote: Sun Nov 20, 2022 5:34 pm
GogaII wrote: Sun Nov 20, 2022 11:59 am
Could anyone advice me something?
Check
NSIS and how they do it.
Thanks, I'll have a look at.
Re: How to make Uninstaller?
Posted: Fri Nov 25, 2022 4:35 pm
by Marc56us
Inno Setup, NSIS, InstallShield, etc. are programs whose behavior is already known to Windows (and signed), which is why their operation does not trigger virus alerts, unlike the program that you create yourself and that seek to delete files and folders without manual intervention by the user.
It is very easy to make a setup with Inno Setup, there is a wizard for the basic operations.
Don't bother to create your own which will be blocked by users' AVs.
The latest version even allows you to create installers that do not require the administrator privilege (as long as you create standard programs)

Re: How to make Uninstaller?
Posted: Fri Nov 25, 2022 5:25 pm
by ChrisR
I agree that Inno Setup, NSIS, InstallShield, msi,... are well proven and the way to do it safely
GogaII wrote: Sun Nov 20, 2022 11:59 am
I used to use a script but now the Windows defender reports that this is a virus and this way doesn't work any more.
If you still want to do it yourself, defender or other AVs should not CRY out if you do it with a command line
Code: Select all
Define Program.s = ProgramFilename()
Define ProgramName.s = GetFilePart(Program)
Define ProgramPath.s = RTrim(GetPathPart(Program), "\")
Define Message.s = "This exe " +#DQUOTE$+ ProgramName +#DQUOTE$+ " will be deleted in 2 seconds." +#CRLF$+
"And the folder containing this exe will be deleted as well." +#CRLF$+#CRLF$+
"So be CAREFUL on the Path to avoid deleting other things accidentally!" +#CRLF$+#CRLF$+
"Path: " +#DQUOTE$+ ProgramPath +#DQUOTE$
If MessageRequester("Self Deleting Exe Example", Message, #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
RunProgram(GetEnvironmentVariable("Comspec"),"/C Timeout 2 && Del /F /Q " +#DQUOTE$+ Program +#DQUOTE$+ " && Rd /S /Q " +#DQUOTE$+ ProgramPath +#DQUOTE$, GetEnvironmentVariable("Windir") + "\System32", #PB_Program_Hide)
EndIf
Re: How to make Uninstaller?
Posted: Mon Nov 28, 2022 2:49 pm
by GogaII
ChrisR wrote: Fri Nov 25, 2022 5:25 pm
.....
RunProgram(GetEnvironmentVariable("Comspec"),"/C Timeout 2 && Del /F /Q " +#DQUOTE$+ Program +#DQUOTE$+ " && Rd /S /Q " +#DQUOTE$+ ProgramPath +#DQUOTE$, GetEnvironmentVariable("Windir") + "\System32", #PB_Program_Hide)
...
Thanks, I'll check this string, but I don't know why , but
Code: Select all
RunProgram(GetEnvironmentVariable("comspec"), "timeout 2 & /c del "+Chr(34)+ProgramFilename()+Chr(34),"", 2)
stopped working well.
P.S. After a lot of hours of searching & creation my own installer&uninstaller I decided to return to Inno Setup

Re: How to make Uninstaller?
Posted: Mon Nov 28, 2022 3:22 pm
by ChrisR
GogaII wrote: Mon Nov 28, 2022 2:49 pm
P.S. After a lot of hours of searching & creation my own installer&uninstaller I decided to return to Inno Setup
It's a good choice, it's proven and it's quite simple with the Inno Setup Script Wizard, you should like it. This is the installer used for PB.
Re: How to make Uninstaller?
Posted: Wed Jan 11, 2023 7:03 pm
by RichAlgeni
Not sure if you're still interested, but this may help:
viewtopic.php?p=573461#p573461
Re: How to make Uninstaller?
Posted: Wed Jan 11, 2023 7:44 pm
by skywalk
I notice the same problems even using temp folder. Aggressive antivirus blocking.
It does not happen with "C:\MyApp\" folders though.
Only with "C:\Program Files\" and "C:\~Temp\" directories.