Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Password protect uninstallation of application

Posted on 2004-10-25
Medium Priority
Last Modified: 2008-10-26
Hi All,

This is a tough one. I'd give more points if I could.

I want the Uninstaller (not VB's uninstaller) to prompt for a password (password would be the Admin password of the application itself, which is setup the first time my app is run, stored and encrypted in the registry), prior to performing the uninstallation.

Anyhow, I've used Inno Setup to create my setup file. If anyone is familiar with this setup utility, and could assist me here, I would be forever grateful.

I imagine it would take some tweaking of the compiled Uninstallation .dat file....quite the difficult task.

Question by:knuckle05
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 53

Expert Comment

by:Ryan Chong
ID: 12407247
You can't, as the files installed on your machine can be deleted physically if you want to delete it manually. You can't prevent a user to delete your installed files, UNLESS you set the permission so that your logon user cannot delete the application files you had installed.
LVL 28

Accepted Solution

vinnyd79 earned 1000 total points
ID: 12417159
As ryancys said,what is to prevent the user from deleting the files? If you still want to password the uninstall here is an idea that will work.

The concept here is to create a seperate password app and write the Inno unistall file onto the end of it. Then when Inno unistall is run,your app will run where you can verify password.If the password is correct, read the inno unistall file data out of the password app and launch. If you want to try this add this routine to your main app to be run after install:

' command button shown for example,you would only want to call this
' routine once after installation
Private Sub Command1_Click()
WeldUninstallFile "unins000.exe", "Passwd.exe"
End Sub

Private Sub WeldUninstallFile(InnoUninstFile As String, PasswdApp As String)
Dim uFileData As String
Dim Pntr As Long, ff As Integer

' open inno uninstall file and read into uFileData
ff = FreeFile
Open InnoUninstFile For Binary Access Read As #ff
uFileData = Space(LOF(ff))
Get #ff, , uFileData
Close #ff

' write uFileData to the back of the password app
ff = FreeFile
Open PasswdApp For Binary Access Write As #ff
Pntr = LOF(ff) + 1
Put #ff, Pntr, Chr$(0) & "<--->" & uFileData ' <---> used as a delimiter
Close #ff

' kill the original inno unistall.exe
Kill InnoUninstFile

' rename password app as inno unistall file
Name PasswdApp As InnoUninstFile

End Sub

Then create a seperate exe to be installed with inno.Compile it and call it passwd.exe

' add 1 textbox called txtPasswd and a command button called cmdOk.
' Compile into Passwd.exe and install to the same directory as your app.

Private Sub cmdOk_Click()
' simple password validation example,replace with your code
' to read from registry
If txtPasswd = "MYPASSWORD" Then
    SpitOutUninstallFile "Uninstall.exe"
End If
End Sub

Private Sub SpitOutUninstallFile(OutputFileName As String)
Dim uFileData As String, mFile As String, arrDat() As String
Dim InnoDat As String, NewDat As String, ff As Integer

If Right$(App.Path, 1) <> "\" Then
    mFile = App.Path & "\" & App.EXEName & ".exe"
    InnoDat = App.Path & "\unins000.dat"
    mFile = App.Path & App.EXEName & ".exe"
    InnoDat = App.Path & "unins000.dat"
End If

' Open This exe file and read binary data into uFileData
ff = FreeFile
Open mFile For Binary Access Read As #ff
uFileData = Space(LOF(ff))
Get #ff, , uFileData
Close #ff

' split file data to get Uninstall file out
arrDat = Split(uFileData, "<--->")

' create new Uninstall File
ff = FreeFile
Open OutputFileName For Binary Access Write As #ff
Put #ff, , arrDat(1)
Close #ff

' get name for new dat file,it must match inno's uninst name w/ .dat ext
NewDat = Left$(OutputFileName, InStrRev(OutputFileName, ".") - 1) & ".dat"

' rename inno dat to new dat name
Name InnoDat As NewDat

' call the extracted Uninstall file
Shell OutputFileName, vbNormalFocus

End Sub


Author Comment

ID: 12423223
Hey vinnyd79,

Thanks for this suggestion, I will try it out ASAP and report back here.

I understand that someone could just delete the physical files from the drive, the thing is, there are some other "monitor type" services installed with my program that aren't easily detectable as I install them in the system folder.

The application I wrote is a web browser for kids, and included with it is a monitoring service that blocks the use of IE  and / or other mainstream browsers.

With a password protected uninstall file, this will at least preserve these monitors that run at startup. Not to say that they still couldn't be bypassed, I mean, they do show up as a running process in the task manager....anyhow, thx for your help, and I'll post back soon!

Author Comment

ID: 12437817

Pure genius!

It works mint, I had to make a few small additions, specifically some error handling in case I cancelled the process (as it would leave files behind) but it works great!

Question: It seems fairly simple to just weld the 2 together, but how come appending the original Inno setup file to the back of my PW app did not cause the EXE to crash? I was really surprised that it worked...

I'm really curious as to how you came up with this solution...pls give me some insight.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question