How to make Uninstaller?

Windows specific forum
GogaII
User
User
Posts: 27
Joined: Sun Nov 15, 2020 10:03 am

How to make Uninstaller?

Post 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?
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: How to make Uninstaller?

Post 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.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: How to make Uninstaller?

Post by Bitblazer »

GogaII wrote: Sun Nov 20, 2022 11:59 am Could anyone advice me something?
Check NSIS and how they do it.
webpage - discord chat links -> purebasic GPT4All
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: How to make Uninstaller?

Post by idle »

Did you try to copy your uninstaller.exe to GetTemporaryDirectory() and run it from there?
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: How to make Uninstaller?

Post 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.
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: How to make Uninstaller?

Post 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.
webpage - discord chat links -> purebasic GPT4All
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: How to make Uninstaller?

Post 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) :wink:
GogaII
User
User
Posts: 27
Joined: Sun Nov 15, 2020 10:03 am

Re: How to make Uninstaller?

Post 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.
GogaII
User
User
Posts: 27
Joined: Sun Nov 15, 2020 10:03 am

Re: How to make Uninstaller?

Post 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.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: How to make Uninstaller?

Post 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)
:wink:
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: How to make Uninstaller?

Post 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
GogaII
User
User
Posts: 27
Joined: Sun Nov 15, 2020 10:03 am

Re: How to make Uninstaller?

Post 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 :(
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: How to make Uninstaller?

Post 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.
User avatar
RichAlgeni
Addict
Addict
Posts: 914
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: How to make Uninstaller?

Post by RichAlgeni »

Not sure if you're still interested, but this may help: viewtopic.php?p=573461#p573461
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How to make Uninstaller?

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply